Browse files

Fixed #15529 -- More permissive geojson syntax in constructor

Thanks Wouter Klein Heerenbrink for the report.
  • Loading branch information...
1 parent 0d9c149 commit c64efe37345cc632e24beb8c7e2a81ef5d3713ba @claudep claudep committed Oct 31, 2013
Showing with 4 additions and 1 deletion.
  1. +3 −0 django/contrib/gis/gdal/tests/test_geom.py
  2. +1 −1 django/contrib/gis/geometry/regex.py
View
3 django/contrib/gis/gdal/tests/test_geom.py
@@ -121,6 +121,9 @@ def test01e_json(self):
self.assertEqual(json.loads(g.json), json.loads(geom.json))
self.assertEqual(json.loads(g.json), json.loads(geom.geojson))
self.assertEqual(OGRGeometry(g.wkt), OGRGeometry(geom.json))
+ # Test input with some garbage content (but valid json) (#15529)
+ geom = OGRGeometry('{"type": "Point", "coordinates": [ 100.0, 0.0 ], "other": "<test>"}')
+ self.assertIsInstance(geom, OGRGeometry)
def test02_points(self):
"Testing Point objects."
View
2 django/contrib/gis/geometry/regex.py
@@ -9,4 +9,4 @@
r'(?P<type>POINT|LINESTRING|LINEARRING|POLYGON|MULTIPOINT|MULTILINESTRING|MULTIPOLYGON|GEOMETRYCOLLECTION)'
r'[ACEGIMLONPSRUTYZ\d,\.\-\(\) ]+)$',
re.I)
-json_regex = re.compile(r'^(\s+)?\{[\s\w,\[\]\{\}\-\."\':]+\}(\s+)?$')
+json_regex = re.compile(r'^(\s+)?\{.*}(\s+)?$', re.DOTALL)

0 comments on commit c64efe3

Please sign in to comment.