diff --git a/django/contrib/gis/geometry/regex.py b/django/contrib/gis/geometry/regex.py index 1b9e2f46f42..22d16cb4c88 100644 --- a/django/contrib/gis/geometry/regex.py +++ b/django/contrib/gis/geometry/regex.py @@ -4,7 +4,7 @@ import re # to prevent potentially malicious input from reaching the underlying C # library. Not a substitute for good Web security programming practices. hex_regex = re.compile(r'^[0-9A-F]+$', re.I) -wkt_regex = re.compile(r'^(SRID=(?P\d+);)?' +wkt_regex = re.compile(r'^(SRID=(?P\-?\d+);)?' r'(?P' r'(?PPOINT|LINESTRING|LINEARRING|POLYGON|MULTIPOINT|MULTILINESTRING|MULTIPOLYGON|GEOMETRYCOLLECTION)' r'[ACEGIMLONPSRUTYZ\d,\.\-\(\) ]+)$', diff --git a/django/contrib/gis/geos/tests/test_geos.py b/django/contrib/gis/geos/tests/test_geos.py index f611dd4d1ad..eb13a62cb98 100644 --- a/django/contrib/gis/geos/tests/test_geos.py +++ b/django/contrib/gis/geos/tests/test_geos.py @@ -182,13 +182,14 @@ class GEOSTest(unittest.TestCase, TestDataMixin): def test01h_ewkt(self): "Testing EWKT." - srid = 32140 - for p in self.geometries.polygons: - ewkt = 'SRID=%d;%s' % (srid, p.wkt) - poly = fromstr(ewkt) - self.assertEqual(srid, poly.srid) - self.assertEqual(srid, poly.shell.srid) - self.assertEqual(srid, fromstr(poly.ewkt).srid) # Checking export + srids = (-1, 32140) + for srid in srids: + for p in self.geometries.polygons: + ewkt = 'SRID=%d;%s' % (srid, p.wkt) + poly = fromstr(ewkt) + self.assertEqual(srid, poly.srid) + self.assertEqual(srid, poly.shell.srid) + self.assertEqual(srid, fromstr(poly.ewkt).srid) # Checking export def test01i_json(self): "Testing GeoJSON input/output (via GDAL)."