While investigating a bug reported against tmda-pending, I found that
it could also happen with tmda-cgi, because it is a problem with the
Pending.Message class.

Summary
-------
There are a small set of messages that email.Parser.Parser can parse
successfully but that email.Generator.Generator cannot successfully
flatten (turn back into a string).  In base TMDA, we use the
HeaderParser class and a Generator descendant that understands
messages parsed by HeaderParser and so we don't run into this
problem.

The Pending.Message class, however, used by tmda-pending and tmda-cgi,
uses the full Parser.  At such time as Util.msg_as_string() is called
on that fully-parsed email.Message.Message object, it dies with an
exception.

This means that

1) The message summary cannot be created.
2) The message cannot be viewed (in tmda-pending only).
3) The message cannot be released.


Fix
---
I have a working fix for tmda-pending, but later realized in
conversation with Jason that tmda-cgi was also affected and the fix
would not work in that case.

A second idea will work for all cases, I believe, but I want to run
this past Gre7g and Jim first to be sure I'm not screwing up some
assumption in tmda-cgi.

There are three locations in the Pending.Message class where
Util.msg_as_string() is called.  I am proposing that I wrap each of
those cases in try/except clause and, in the unlikely event that the
Generator.flatten() method fails, the code will re-parse the original
message using HeaderParser and will then flatten that new message
object and use the resulting string.

I had initially thought to just use HeaderParser only (in Message's
__init__ method) for all messages but it turns out that tmda-cgi
actually shows the MIME parts of the message in the browser, which
would no longer be possible with header parsed messages.

The solution I propose would allow tmda-cgi to use the fully parsed
message object for viewing purposes but would allow both tmda-cgi and
tmda-pending to create a summary and to release the message without
the error that happens now.

I'm curious if this solution will work for tmda-cgi or if there are
any assumptions that will break because of this.  The latter case
seems unlikely, but I want to double-check before going ahead.


Tim

_________________________________________________
tmda-workers mailing list ([EMAIL PROTECTED])
http://tmda.net/lists/listinfo/tmda-workers

Reply via email to