Opened 7 years ago

Last modified 7 years ago

#28105 closed Bug

BaseGeometryWidget.get_context() crashes if attrs contains the name of an existing key — at Version 1

Reported by: Dylan Verheul Owned by: nobody
Component: GIS Version: 1.11
Severity: Release blocker Keywords: gis, forms, widgets
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by Tim Graham)

Incontrib.gis.forms.widgets there is this part (line 67 in current master):

context = self.build_attrs(self.attrs, dict(
    name=name,
    module='geodjango_%s' % name.replace('-', '_'),  # JS-safe
    serialized=self.serialize(value),
    geom_type=gdal.OGRGeomType(self.attrs['geom_type']),
    STATIC_URL=settings.STATIC_URL,
    LANGUAGE_BIDI=translation.get_language_bidi(),
    **attrs
))

If attrs also contains a key 'geom_type' this leads to an inevitable crash.

This should probaly be something like:

context_kwargs = attrs.copy()
context_kwargs.update(dict(
    name=name,
    module='geodjango_%s' % name.replace('-', '_'),  # JS-safe
    serialized=self.serialize(value),
    geom_type=gdal.OGRGeomType(self.attrs['geom_type']),
    STATIC_URL=settings.STATIC_URL,
    LANGUAGE_BIDI=translation.get_language_bidi(),
))

Currently this causes django-bootstrap3 to fail for Django 1.11.

Change History (1)

comment:1 by Tim Graham, 7 years ago

Component: FormsGIS
Description: modified (diff)
Severity: NormalRelease blocker
Summary: Missing check in django.contrib.forms.widgetsBaseGeometryWidget.get_context() crashes if attrs contains the name of an existing key
Triage Stage: UnreviewedAccepted

Could you explain more about the use case that causes the crash? If you could write a test for tests/gis_tests/test_geoforms.py, that would be ideal.

Note: See TracTickets for help on using tickets.
Back to Top