Changes between Initial Version and Version 2 of Ticket #37492
- Timestamp:
- Nov 9, 2026, 5:25:49 PM (3 weeks ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #37492
- Property Has patch set
- Property Keywords GeoJSON added
- Property Patch needs improvement set
- Property Severity Normal → Low
- Property Triage Stage Unreviewed → Accepted
- Property Summary GeometryField.to_python() crashes with GDALException on invalid GeoJSON when the widget has no deserialize() → GeometryField(widget=forms.TextInput).to_python() doesn't handle GDALException from invalid GeoJSON
-
Ticket #37492 – Description
initial v2 1 1 #29978 made `GeometryField.to_python()` catch `GDALException` from `widget.deserialize()`. However, when the widget has no `deserialize()` method (e.g. `widget=forms.TextInput`, which `test_field_with_text_widget` covers), `to_python()` calls `GEOSGeometry()` directly and only catches `GEOSException`, `ValueError` and `TypeError`. For GeoJSON input that GDAL rejects, `GEOSGeometry()` raises `GDALException`, so `clean()` crashes (HTTP 500) instead of raising a `ValidationError`: 2 2 3 ```python 3 {{{#!py 4 4 from django import forms as django_forms 5 5 from django.contrib.gis import forms 6 6 forms.GeometryField(widget=django_forms.TextInput).clean("{}") 7 7 # GDALException: Invalid geometry pointer returned from "OGR_G_CreateGeometryFromJson". 8 ``` 8 }}} 9 9 10 10 `'{"type": "Foo"}'`, `'{"type": "Point"}'` and `'{"type": "Point", "coordinates": "x"}'` crash the same way. This reproduces on 6.1.2, 6.1.3 and main. The default widget isn't affected, because `BaseGeometryWidget.deserialize()` catches `GDALException`.