Invalid XPM file causes 500 error

Bug #865210 reported by Anthony Lenton on 2011-10-03
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Developer registration portal
Łukasz Czyżykowski

Bug Description

When simple invalid xpm files are submitted with an app, the app crashes and burns with the following traceback:

Traceback (most recent call last):
  File "/srv/", line 111, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/srv/", line 79, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/srv/", line 23, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/srv/", line 84, in inner_decorator
    return func(request, *args, **kwargs)
  File "/srv/", line 326, in application_update
    if form.is_valid():
  File "/srv/", line 121, in is_valid
    return self.is_bound and not bool(self.errors)
  File "/srv/", line 112, in _get_errors
  File "/srv/", line 267, in full_clean
  File "/srv/", line 287, in _clean_fields
    value = getattr(self, 'clean_%s' % name)()
  File "/srv/", line 91, in clean_icon_64
    return self._clean_icon(64)
  File "/srv/", line 75, in _clean_icon
    icon =
  File "/usr/lib/python2.6/dist-packages/PIL/", line 1976, in open
    return factory(fp, filename)
  File "/usr/lib/python2.6/dist-packages/PIL/", line 91, in __init__
  File "/usr/lib/python2.6/dist-packages/PIL/", line 93, in _open
    raise ValueError, "cannot read this XPM file"
ValueError: cannot read this XPM file

For example, you can try submitting a file called "test.xpm", containing "foo".

Changed in developer-portal:
status: New → Confirmed
importance: Undecided → Medium

The traceback here is from slightly broken XPM, more complicated than just "foo". When submitting "foo", the error is:
File "/usr/lib/pymodules/python2.6/django/core/handlers/" in get_response
  92. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/pymodules/python2.6/django/views/decorators/" in _wrapped_view_func
  44. response = view_func(request, *args, **kwargs)
File "/usr/lib/pymodules/python2.6/django/contrib/auth/" in __call__
  78. return self.view_func(request, *args, **kwargs)
File "/srv/" in inner_decorator
  83. return func(request, *args, **kwargs)
File "/srv/" in application_update
  319. if form.is_valid():
File "/usr/lib/pymodules/python2.6/django/forms/" in is_valid
  120. return self.is_bound and not bool(self.errors)
File "/usr/lib/pymodules/python2.6/django/forms/" in _get_errors
  111. self.full_clean()
File "/usr/lib/pymodules/python2.6/django/forms/" in full_clean
  243. value = getattr(self, 'clean_%s' % name)()
File "/srv/" in clean_icon_16
  96. return self._clean_icon(16)
File "/srv/" in _clean_icon
  72. icon =
File "/usr/lib/python2.6/dist-packages/PIL/" in open
  1980. raise IOError("cannot identify image file")

IOError instead of ValueError.

In the end I added handling both cases (IOError and ValueError).

tags: added: kb-defect sp-1
Changed in developer-portal:
status: Confirmed → Fix Committed
assignee: nobody → Łukasz Czyżykowski (lukasz-czyzykowski)
Changed in developer-portal:
milestone: none → 11.11
Changed in developer-portal:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers