Fixed #16864 -- WKT regex now allows negative SRIDs. Thanks, Marcel Dancak for bug report and initial patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16843 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Justin Bronn 2011-09-16 21:19:30 +00:00
parent 00678334aa
commit f97a574196
2 changed files with 9 additions and 8 deletions

View File

@ -4,7 +4,7 @@ import re
# to prevent potentially malicious input from reaching the underlying C # to prevent potentially malicious input from reaching the underlying C
# library. Not a substitute for good Web security programming practices. # library. Not a substitute for good Web security programming practices.
hex_regex = re.compile(r'^[0-9A-F]+$', re.I) 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<wkt>'
r'(?P<type>POINT|LINESTRING|LINEARRING|POLYGON|MULTIPOINT|MULTILINESTRING|MULTIPOLYGON|GEOMETRYCOLLECTION)' r'(?P<type>POINT|LINESTRING|LINEARRING|POLYGON|MULTIPOINT|MULTILINESTRING|MULTIPOLYGON|GEOMETRYCOLLECTION)'
r'[ACEGIMLONPSRUTYZ\d,\.\-\(\) ]+)$', r'[ACEGIMLONPSRUTYZ\d,\.\-\(\) ]+)$',

View File

@ -182,7 +182,8 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
def test01h_ewkt(self): def test01h_ewkt(self):
"Testing EWKT." "Testing EWKT."
srid = 32140 srids = (-1, 32140)
for srid in srids:
for p in self.geometries.polygons: for p in self.geometries.polygons:
ewkt = 'SRID=%d;%s' % (srid, p.wkt) ewkt = 'SRID=%d;%s' % (srid, p.wkt)
poly = fromstr(ewkt) poly = fromstr(ewkt)