Ticket #15529: 15529-2.diff

File 15529-2.diff, 1.4 KB (added by Claude Paroz, 12 years ago)

Same patch with test

  • django/contrib/gis/gdal/tests/test_geom.py

    diff --git a/django/contrib/gis/gdal/tests/test_geom.py b/django/contrib/gis/gdal/tests/test_geom.py
    index 9b8ae6a..0410d92 100644
    a b class OGRGeomTest(unittest.TestCase, TestDataMixin):  
    116116                self.assertEqual(json.loads(g.json), json.loads(geom.json))
    117117                self.assertEqual(json.loads(g.json), json.loads(geom.geojson))
    118118            self.assertEqual(OGRGeometry(g.wkt), OGRGeometry(geom.json))
     119        # Test input with some garbage content (#15529)
     120        geom = OGRGeometry('{"type": "Point", "coordinates": [ 100.0, 0.0 ], "other": "<test>"}')
     121        self.assertIsInstance(geom, OGRGeometry)
    119122
    120123    def test02_points(self):
    121124        "Testing Point objects."
  • django/contrib/gis/geometry/regex.py

    diff --git a/django/contrib/gis/geometry/regex.py b/django/contrib/gis/geometry/regex.py
    index 22d16cb..7dbcbfa 100644
    a b wkt_regex = re.compile(r'^(SRID=(?P<srid>\-?\d+);)?'  
    99                       r'(?P<type>POINT|LINESTRING|LINEARRING|POLYGON|MULTIPOINT|MULTILINESTRING|MULTIPOLYGON|GEOMETRYCOLLECTION)'
    1010                       r'[ACEGIMLONPSRUTYZ\d,\.\-\(\) ]+)$',
    1111                       re.I)
    12 json_regex = re.compile(r'^(\s+)?\{[\s\w,\[\]\{\}\-\."\':]+\}(\s+)?$')
     12json_regex = re.compile(r'^(\s+)?\{.*}(\s+)?$', re.DOTALL)
Back to Top