diff options
| author | Claude Paroz <claude@2xlibre.net> | 2013-10-31 18:15:54 +0100 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2013-10-31 18:15:54 +0100 |
| commit | c64efe37345cc632e24beb8c7e2a81ef5d3713ba (patch) | |
| tree | 770ea1e73324fa1ac767b53dc1404ea5d7a4c6d2 | |
| parent | 0d9c1499901480ed52c08e1b94ecc80c7b55bc0e (diff) | |
Fixed #15529 -- More permissive geojson syntax in constructor
Thanks Wouter Klein Heerenbrink for the report.
| -rw-r--r-- | django/contrib/gis/gdal/tests/test_geom.py | 3 | ||||
| -rw-r--r-- | django/contrib/gis/geometry/regex.py | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/django/contrib/gis/gdal/tests/test_geom.py b/django/contrib/gis/gdal/tests/test_geom.py index c547135b17..65d78a1735 100644 --- a/django/contrib/gis/gdal/tests/test_geom.py +++ b/django/contrib/gis/gdal/tests/test_geom.py @@ -121,6 +121,9 @@ class OGRGeomTest(unittest.TestCase, TestDataMixin): 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." diff --git a/django/contrib/gis/geometry/regex.py b/django/contrib/gis/geometry/regex.py index 22d16cb4c8..7dbcbfa4e7 100644 --- a/django/contrib/gis/geometry/regex.py +++ b/django/contrib/gis/geometry/regex.py @@ -9,4 +9,4 @@ wkt_regex = re.compile(r'^(SRID=(?P<srid>\-?\d+);)?' 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) |
