Changes between Initial Version and Version 2 of Ticket #37492


Ignore:
Timestamp:
Nov 9, 2026, 5:25:49 PM (3 weeks ago)
Author:
Jacob Walls
Comment:

That seems fair. Setting PNI due to PR limit.

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  
    11#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`:
    22
    3 ```python
     3{{{#!py
    44from django import forms as django_forms
    55from django.contrib.gis import forms
    66forms.GeometryField(widget=django_forms.TextInput).clean("{}")
    77# GDALException: Invalid geometry pointer returned from "OGR_G_CreateGeometryFromJson".
    8 ```
     8}}}
    99
    1010`'{"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`.
Back to Top