Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Justin Bronn authored September 16, 2011
2  django/contrib/gis/geometry/regex.py
@@ -4,7 +4,7 @@
4 4
 # to prevent potentially malicious input from reaching the underlying C
5 5
 # library.  Not a substitute for good Web security programming practices.
6 6
 hex_regex = re.compile(r'^[0-9A-F]+$', re.I)
7  
-wkt_regex = re.compile(r'^(SRID=(?P<srid>\d+);)?'
  7
+wkt_regex = re.compile(r'^(SRID=(?P<srid>\-?\d+);)?'
8 8
                        r'(?P<wkt>'
9 9
                        r'(?P<type>POINT|LINESTRING|LINEARRING|POLYGON|MULTIPOINT|MULTILINESTRING|MULTIPOLYGON|GEOMETRYCOLLECTION)'
10 10
                        r'[ACEGIMLONPSRUTYZ\d,\.\-\(\) ]+)$',
15  django/contrib/gis/geos/tests/test_geos.py
@@ -182,13 +182,14 @@ def test01g_create_wkb(self):
182 182
 
183 183
     def test01h_ewkt(self):
184 184
         "Testing EWKT."
185  
-        srid = 32140
186  
-        for p in self.geometries.polygons:
187  
-            ewkt = 'SRID=%d;%s' % (srid, p.wkt)
188  
-            poly = fromstr(ewkt)
189  
-            self.assertEqual(srid, poly.srid)
190  
-            self.assertEqual(srid, poly.shell.srid)
191  
-            self.assertEqual(srid, fromstr(poly.ewkt).srid) # Checking export
  185
+        srids = (-1, 32140)
  186
+        for srid in srids:
  187
+            for p in self.geometries.polygons:
  188
+                ewkt = 'SRID=%d;%s' % (srid, p.wkt)
  189
+                poly = fromstr(ewkt)
  190
+                self.assertEqual(srid, poly.srid)
  191
+                self.assertEqual(srid, poly.shell.srid)
  192
+                self.assertEqual(srid, fromstr(poly.ewkt).srid) # Checking export
192 193
 
193 194
     def test01i_json(self):
194 195
         "Testing GeoJSON input/output (via GDAL)."

0 notes on commit f97a574

Please sign in to comment.
Something went wrong with that request. Please try again.