Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #16864 -- WKT regex now allows negative SRIDs. Thanks, Marcel D…

…ancak for bug report and initial patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16843 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit f97a574196102ef2479da4e519d7cffc7a5fdf6c 1 parent 0067833
@jbronn jbronn authored
View
2  django/contrib/gis/geometry/regex.py
@@ -4,7 +4,7 @@
# 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<srid>\d+);)?'
+wkt_regex = re.compile(r'^(SRID=(?P<srid>\-?\d+);)?'
r'(?P<wkt>'
r'(?P<type>POINT|LINESTRING|LINEARRING|POLYGON|MULTIPOINT|MULTILINESTRING|MULTIPOLYGON|GEOMETRYCOLLECTION)'
r'[ACEGIMLONPSRUTYZ\d,\.\-\(\) ]+)$',
View
15 django/contrib/gis/geos/tests/test_geos.py
@@ -182,13 +182,14 @@ def test01g_create_wkb(self):
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)."
Please sign in to comment.
Something went wrong with that request. Please try again.