Re: [Django] #36246: BaseGeometryWidget.deserialize() does not catch GDALException from malformed GeoJSON (was: Malformed GeoJSON throws server error)

2 views
Skip to first unread message

Django

unread,
Mar 12, 2025, 3:49:41 AM3/12/25
to django-...@googlegroups.com
#36246: BaseGeometryWidget.deserialize() does not catch GDALException from
malformed GeoJSON
------------------------------+------------------------------------
Reporter: David Buhler | Owner: (none)
Type: Bug | Status: new
Component: GIS | Version: 4.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Changes (by Sarah Boyce):

* cc: Claude Paroz (added)
* stage: Unreviewed => Accepted
* summary: Malformed GeoJSON throws server error =>
BaseGeometryWidget.deserialize() does not catch GDALException from
malformed GeoJSON

Comment:

Thank you for the report

Replicated, possible test
{{{#!diff
diff --git a/tests/gis_tests/test_geoforms.py
b/tests/gis_tests/test_geoforms.py
index c351edaaad..b6068948f3 100644
--- a/tests/gis_tests/test_geoforms.py
+++ b/tests/gis_tests/test_geoforms.py
@@ -435,6 +435,19 @@ class GeometryWidgetTests(SimpleTestCase):
context = widget.get_context("geometry", None, None)
self.assertEqual(context["geom_type"], "Geometry")

+ def test_invalid_values(self):
+ bad_inputs = [
+ "POINT(5)",
+ "MULTI POLYGON(((0 0, 0 1, 1 1, 1 0, 0 0)))",
+ "BLAH(0 0, 1 1)",
+ '{"type": "FeatureCollection", "features": ['
+ '{"geometry": {"type": "Point", "coordinates": [508375,
148905]}, '
+ '"type": "Feature"}]}',
+ ]
+ for input in bad_inputs:
+ with self.subTest(input=input):
+
self.assertIsNone(BaseGeometryWidget().deserialize(input))
+
def test_subwidgets(self):
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36246#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Reply all
Reply to author
Forward
0 new messages