Opened 12 years ago

Closed 10 years ago

#3211 closed defect (fixed)

admin crash when uploading an e-mail message as a text file

Reported by: Antti Kaihola Owned by: nobody
Component: contrib.admin Version: master
Severity: normal Keywords:
Cc: gt4329b@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


In r4259, if I try to upload an e-mail message saved from Mozilla Thunderbird (an .eml file) in admin, I get this error message:

Traceback (most recent call last):

  File "/django/core/servers/", line 272, in run
    self.result = application(self.environ, self.start_response)

  File "/django/core/servers/", line 614, in __call__
    return self.application(environ, start_response)

  File "/django/core/handlers/", line 189, in __call__
    response = self.get_response(request)

  File "/django/core/handlers/", line 111, in get_response
    return debug.technical_500_response(request, *sys.exc_info())

  File "/django/views/", line 131, in technical_500_response
    return HttpResponseServerError(t.render(c), mimetype='text/html')

  File "/django/template/", line 160, in render
    return self.nodelist.render(context)

  File "/django/template/", line 694, in render
    bits.append(self.render_node(node, context))

  File "/django/template/", line 722, in render_node
    raise wrapped

TemplateSyntaxError: Caught an exception while rendering: Nested MIME messages are not supported

Original Traceback (most recent call last):
  File "/django/template/", line 712, in render_node
    result = node.render(context)
  File "/django/template/", line 762, in render
    output = self.filter_expression.resolve(context)
  File "/django/template/", line 555, in resolve
    obj = resolve_variable(self.var, context)
  File "/django/template/", line 640, in resolve_variable
    current = current[bits[0]]
  File "/django/http/", line 31, in __getitem__
    for d in (self.POST, self.GET):
  File "/django/core/handlers/", line 136, in _get_post
  File "/django/core/handlers/", line 114, in _load_post_and_files
    self._post, self._files = http.parse_file_upload(header_dict, self.raw_post_data)
  File "/django/http/", line 61, in parse_file_upload
    assert type([]) != type(submessage.get_payload()), "Nested MIME messages are not supported"
AssertionError: Nested MIME messages are not supported

Here's my model:

class EmailUploadBugTestModel(models.Model):
	upload = models.FileField(upload_to='files/%Y/%m/%d')
	class Admin: pass

Attachments (1)

allow_MHTML_upload_patch.r6660.diff (1.3 KB) - added by rfmorris 11 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 12 years ago by Antti Kaihola

My browser is Firefox 2.0, in case that makes any difference.

comment:2 Changed 12 years ago by Chris Beaven

Triage Stage: UnreviewedAccepted

comment:3 Changed 11 years ago by rfmorris

Cc: gt4329b@… added
Has patch: set
Patch needs improvement: set

I recently ran into the same problem, so I came up with my own monkeypatch for handling message/rfc822 content types (nested MIME messages). Make no mistake: it's a hack, as it just removes the blind assert and replaces it with handling code that grabs the first payload from the submessage.

Changed 11 years ago by rfmorris

comment:4 Changed 10 years ago by Dennis Kaarsemaker

Has patch: unset
Patch needs improvement: unset
Resolution: fixed
Status: newclosed

This has been fixed at some point between this bug being filed and now. There no longer are checks for nested mime messages and uploading .eml files with embedded emails works as expected.

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