From 40aa73fb25d2e7cba347e3c7e4618b7dd82fe24f Mon Sep 17 00:00:00 2001 From: Christian Spurk Date: Mon, 22 Oct 2012 11:07:50 +0200 Subject: [PATCH 1/2] some pattern-restricted values now better match the metadata schema MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This partly fixes #683. It is still the case, however, that our Django validator for `httpURI` values does not make sure that corresponding values match the `xs:anyURI` type’s value space. --- metashare/repository/models.py | 11 ++++++++--- misc/tools/generateMeta/clazzbase.py | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/metashare/repository/models.py b/metashare/repository/models.py index b2c13c27f..f48ca2734 100644 --- a/metashare/repository/models.py +++ b/metashare/repository/models.py @@ -29,10 +29,15 @@ LOGGER = logging.getLogger(__name__) LOGGER.addHandler(LOG_HANDLER) -EMAILADDRESS_VALIDATOR = RegexValidator(r'[^@]+@[^\.]+\..+', +# Note: we have to use the '^' and '$' anchors in the following regular +# expressions as for some reason the RegexValidator does not try to match the +# whole string against the regex but it just searches for a matching substring; +# in addition we have to use the negative lookahead assertion at the end of the +# regular expressions as Python's regex engine otherwise always ignores a single +# trailing newline +EMAILADDRESS_VALIDATOR = RegexValidator(r'^[^@]+@[^\.]+\..+(?!\r?\n)$', 'Not a valid emailAddress value.', ValidationError) - -HTTPURI_VALIDATOR = RegexValidator(r'(https?://.*|ftp://.*|www*)', +HTTPURI_VALIDATOR = RegexValidator(r'^(https?://.*|ftp://.*|www.*)(?!\r?\n)$', 'Not a valid httpURI value.', ValidationError) # namespace of the META-SHARE metadata XML Schema diff --git a/misc/tools/generateMeta/clazzbase.py b/misc/tools/generateMeta/clazzbase.py index c78cf5d7d..9596e1ccb 100644 --- a/misc/tools/generateMeta/clazzbase.py +++ b/misc/tools/generateMeta/clazzbase.py @@ -175,10 +175,15 @@ LOGGER = logging.getLogger(__name__) LOGGER.addHandler(LOG_HANDLER) -EMAILADDRESS_VALIDATOR = RegexValidator(r'[^@]+@[^\.]+\..+', +# Note: we have to use the '^' and '$' anchors in the following regular +# expressions as for some reason the RegexValidator does not try to match the +# whole string against the regex but it just searches for a matching substring; +# in addition we have to use the negative lookahead assertion at the end of the +# regular expressions as Python's regex engine otherwise always ignores a single +# trailing newline +EMAILADDRESS_VALIDATOR = RegexValidator(r'^[^@]+@[^\.]+\..+(?!\\r?\\n)$', 'Not a valid emailAddress value.', ValidationError) - -HTTPURI_VALIDATOR = RegexValidator(r'(https?://.*|ftp://.*|www*)', +HTTPURI_VALIDATOR = RegexValidator(r'^(https?://.*|ftp://.*|www.*)(?!\\r?\\n)$', 'Not a valid httpURI value.', ValidationError) # namespace of the META-SHARE metadata XML Schema From 7fcbdf46e7674a4b34483d376db8a66df8c10fa0 Mon Sep 17 00:00:00 2001 From: Christian Spurk Date: Mon, 22 Oct 2012 13:06:16 +0200 Subject: [PATCH 2/2] fix various test resource in order to make sure they are schema valid --- .../fixtures/creators-projects-1.xml | 27 +++++--- .../fixtures/creators-projects-2.xml | 25 +++++--- .../fixtures/creators-projects-3.xml | 26 +++++--- .../fixtures/creators-projects-4.xml | 26 +++++--- .../fixtures/creators-projects-5.xml | 62 +++++++++++-------- .../recommendations/fixtures/elra112.xml | 27 +++++--- .../recommendations/fixtures/elra135.xml | 25 +++++--- .../recommendations/fixtures/elra260.xml | 24 ++++--- .../recommendations/fixtures/elra295.xml | 24 ++++--- metashare/recommendations/tests.py | 4 +- 10 files changed, 172 insertions(+), 98 deletions(-) diff --git a/metashare/recommendations/fixtures/creators-projects-1.xml b/metashare/recommendations/fixtures/creators-projects-1.xml index e4024b427..1eb05bdb0 100644 --- a/metashare/recommendations/fixtures/creators-projects-1.xml +++ b/metashare/recommendations/fixtures/creators-projects-1.xml @@ -11,11 +11,20 @@ répartie en deux sous-ensembles. + http://catalog.elra.info/product_info.php?products_id=1076 NOT_DEFINED_FOR_V2 - http://catalog.elra.info/product_info.php?products_id=1076 - ELRA-S0288 + + available-unrestrictedUse + + AGPL + + + + Test + test@example.org + 2005-05-12 @@ -25,7 +34,7 @@ mapelli@elda.org http://www.elda.org
55-57 rue Brillat-Savarin
- 75013 + 75013 Paris France +1 43 13 33 33 @@ -37,12 +46,6 @@ 1.0 2008-10-07 - - available-unrestrictedUse - - AGPL - - nlpApplications @@ -81,6 +84,12 @@ tha Thai + + + 123456 + entries + + diff --git a/metashare/recommendations/fixtures/creators-projects-2.xml b/metashare/recommendations/fixtures/creators-projects-2.xml index 3595d36c9..a66ce7f97 100644 --- a/metashare/recommendations/fixtures/creators-projects-2.xml +++ b/metashare/recommendations/fixtures/creators-projects-2.xml @@ -16,11 +16,20 @@ fourni avec une interprétation linguistique. + http://catalog.elra.info/product_info.php?products_id=1102 NOT_DEFINED_FOR_V2 - http://catalog.elra.info/product_info.php?products_id=1102 - ELRA-W0050 + + available-unrestrictedUse + + AGPL + + + + Test + test@example.org + 2005-05-12 @@ -30,7 +39,7 @@ mapelli@elda.org http://www.elda.org
55-57 rue Brillat-Savarin
- 75013 + 75013 Paris France +1 43 13 33 33 @@ -42,12 +51,6 @@ 1.0 2009-06-09 - - available-unrestrictedUse - - AGPL - - @@ -75,6 +78,10 @@ por Portuguese + + 123465 + entries + Plain text diff --git a/metashare/recommendations/fixtures/creators-projects-3.xml b/metashare/recommendations/fixtures/creators-projects-3.xml index 94d86dad4..17add5a29 100644 --- a/metashare/recommendations/fixtures/creators-projects-3.xml +++ b/metashare/recommendations/fixtures/creators-projects-3.xml @@ -1,5 +1,5 @@ - + EuroWordNet Spanish EuroWordNet espagnol @@ -11,10 +11,20 @@ A. Wordnets disponibles - NOT_DEFINED_FOR_V2 http://catalog.elra.info/product_info.php?products_id=547 + NOT_DEFINED_FOR_V2 ELRA-M0017 + + available-unrestrictedUse + + AGPL + + + + Test + test@example.org + 2005-05-12 @@ -24,7 +34,7 @@ mapelli@elda.org http://www.elda.org
55-57 rue Brillat-Savarin
- 75013 + 75013 Paris France +1 43 13 33 33 @@ -36,12 +46,6 @@ 1.0 2005-05-30 - - available-unrestrictedUse - - AGPL - - @@ -79,6 +83,10 @@ + + 123 + elements + diff --git a/metashare/recommendations/fixtures/creators-projects-4.xml b/metashare/recommendations/fixtures/creators-projects-4.xml index 443d9756e..77b262cbb 100644 --- a/metashare/recommendations/fixtures/creators-projects-4.xml +++ b/metashare/recommendations/fixtures/creators-projects-4.xml @@ -1,5 +1,5 @@ - + VERBA Polytechnic and Plurilingual Terminological Database - I-MN Outfitting @@ -9,10 +9,20 @@ * Entries for English-Spanish - NOT_DEFINED_FOR_V2 http://catalog.elra.info/product_info.php?products_id=293 + NOT_DEFINED_FOR_V2 ELRA-T0218 + + available-unrestrictedUse + + AGPL + + + + Test + test@example.org + 2005-05-12 @@ -22,7 +32,7 @@ mapelli@elda.org http://www.elda.org
55-57 rue Brillat-Savarin
- 75013 + 75013 Paris France +1 43 13 33 33 @@ -34,12 +44,6 @@ 1.0 2006-09-27 - - available-unrestrictedUse - - AGPL - - test-project-1 @@ -76,6 +80,10 @@ + + 123 + elements + diff --git a/metashare/recommendations/fixtures/creators-projects-5.xml b/metashare/recommendations/fixtures/creators-projects-5.xml index bff58de54..4d156648b 100644 --- a/metashare/recommendations/fixtures/creators-projects-5.xml +++ b/metashare/recommendations/fixtures/creators-projects-5.xml @@ -13,31 +13,10 @@ « front-end » d’un système DSR (Distributed Speech Recognition – Reconnaissance de la parole distribuée). - NOT_DEFINED_FOR_V2 http://catalog.elra.info/product_info.php?products_id=1015 + NOT_DEFINED_FOR_V2 ELRA-AURORA-CD0005 - - 2005-05-12 - - Valérie - Mapelli - - mapelli@elda.org - http://www.elda.org -
55-57 rue Brillat-Savarin
- 75013 - Paris - France - +1 43 13 33 33 - +1 43 14 33 30 -
-
-
- - 1.0 - 2010-03-12 - available-restrictedUse @@ -46,7 +25,7 @@ 250.00 commercial - False + false ELRA @@ -56,7 +35,7 @@ 250.00 academic - False + false ELRA @@ -66,7 +45,7 @@ 250.00 commercial - True + true ELRA @@ -76,12 +55,37 @@ 250.00 academic - True + true ELRA 2007-10-08 + + Test + test@example.org + + + 2005-05-12 + + Valérie + Mapelli + + mapelli@elda.org + http://www.elda.org +
55-57 rue Brillat-Savarin
+ 75013 + Paris + France + +1 43 13 33 33 + +1 43 14 33 30 +
+
+
+ + 1.0 + 2010-03-12 + nlpApplications @@ -101,6 +105,12 @@ eng English + + + 123 + elements + + diff --git a/metashare/recommendations/fixtures/elra112.xml b/metashare/recommendations/fixtures/elra112.xml index d32ca3061..aefa387d8 100644 --- a/metashare/recommendations/fixtures/elra112.xml +++ b/metashare/recommendations/fixtures/elra112.xml @@ -89,11 +89,20 @@ avec sa transcription phonétique en SAMPA est également fourni. + http://catalog.elra.info/product_info.php?products_id=1076 NOT_DEFINED_FOR_V2 - http://catalog.elra.info/product_info.php?products_id=1076 - ELRA-S0288 + + available-unrestrictedUse + + AGPL + + + + Test + test@example.org + 2005-05-12 @@ -103,7 +112,7 @@ mapelli@elda.org http://www.elda.org
55-57 rue Brillat-Savarin
- 75013 + 75013 Paris France +1 43 13 33 33 @@ -115,12 +124,6 @@ 1.0 2008-10-07 - - available-unrestrictedUse - - AGPL - - nlpApplications @@ -146,6 +149,12 @@ tha Thai + + + 132 + elements + + diff --git a/metashare/recommendations/fixtures/elra135.xml b/metashare/recommendations/fixtures/elra135.xml index f5602f69b..71547f49c 100644 --- a/metashare/recommendations/fixtures/elra135.xml +++ b/metashare/recommendations/fixtures/elra135.xml @@ -121,11 +121,20 @@ corpus peut être effectuée en ligne: http://cintil.ul.pt/ + http://catalog.elra.info/product_info.php?products_id=1102 NOT_DEFINED_FOR_V2 - http://catalog.elra.info/product_info.php?products_id=1102 - ELRA-W0050 + + available-unrestrictedUse + + AGPL + + + + Test + test@example.org + 2005-05-12 @@ -135,7 +144,7 @@ mapelli@elda.org http://www.elda.org
55-57 rue Brillat-Savarin
- 75013 + 75013 Paris France +1 43 13 33 33 @@ -147,12 +156,6 @@ 1.0 2009-06-09 - - available-unrestrictedUse - - AGPL - - corpus @@ -166,6 +169,10 @@ por Portuguese + + 123 + elements + Plain text diff --git a/metashare/recommendations/fixtures/elra260.xml b/metashare/recommendations/fixtures/elra260.xml index 39b4b8b35..db13211d8 100644 --- a/metashare/recommendations/fixtures/elra260.xml +++ b/metashare/recommendations/fixtures/elra260.xml @@ -235,10 +235,20 @@ http://www.hum.uva.nl/~ewnaux enregistrements de l'index inter-lingue - NOT_DEFINED_FOR_V2 http://catalog.elra.info/product_info.php?products_id=547 + NOT_DEFINED_FOR_V2 ELRA-M0017 + + available-unrestrictedUse + + AGPL + + + + Test + test@example.org + 2005-05-12 @@ -248,7 +258,7 @@ mapelli@elda.org http://www.elda.org
55-57 rue Brillat-Savarin
- 75013 + 75013 Paris France +1 43 13 33 33 @@ -260,12 +270,6 @@ 1.0 2005-05-30 - - available-unrestrictedUse - - AGPL - - EuroWordNet @@ -294,6 +298,10 @@ + + 123 + elements + diff --git a/metashare/recommendations/fixtures/elra295.xml b/metashare/recommendations/fixtures/elra295.xml index 970b8683b..65fd01bb3 100644 --- a/metashare/recommendations/fixtures/elra295.xml +++ b/metashare/recommendations/fixtures/elra295.xml @@ -48,10 +48,20 @@ une abréviation, une information sur l'usage et des étiquettes grammaticales.Format: ASCIISupport : disquette - NOT_DEFINED_FOR_V2 http://catalog.elra.info/product_info.php?products_id=293 + NOT_DEFINED_FOR_V2 ELRA-T0218 + + available-unrestrictedUse + + AGPL + + + + Test + test@example.org + 2005-05-12 @@ -61,7 +71,7 @@ mapelli@elda.org http://www.elda.org
55-57 rue Brillat-Savarin
- 75013 + 75013 Paris France +1 43 13 33 33 @@ -73,12 +83,6 @@ 1.0 2006-09-27 - - available-unrestrictedUse - - AGPL - - lexicalConceptualResource @@ -105,6 +109,10 @@ + + 123 + elements + diff --git a/metashare/recommendations/tests.py b/metashare/recommendations/tests.py index 5b70d82d3..df13fcdd6 100644 --- a/metashare/recommendations/tests.py +++ b/metashare/recommendations/tests.py @@ -502,10 +502,10 @@ def test_views(self): saveLRStats(self.res_3, UPDATE_STAT) saveLRStats(self.res_4, UPDATE_STAT) self.assertEquals(9, len(LRStats.objects.all())) - self.assertEquals(186, len(UsageStats.objects.all())) + self.assertEquals(219, len(UsageStats.objects.all())) remove_resource(self.res_1.storage_object) self.assertEquals(7, len(LRStats.objects.all())) - self.assertEquals(139, len(UsageStats.objects.all())) + self.assertEquals(163, len(UsageStats.objects.all())) def test_downloads(self): # client 1 downloads all 4 resources