[Email-SIG] Problem Report for email.Utils.decode_rfc2231

Mark Sapiro msapiro at value.net
Sat Jul 8 00:45:04 CEST 2006

Georg Graf wrote:
>There are 2 assumptions in email.Utils.decode_rfc2231 I do not
>Assumption 1: The string passed either has zero single-quotes or
>more than 1.
>Assumption 2: If the string has two or more single-quotes the
>meaning of the parts is different. I dont know rfc2231, so what
>do I write. But still it seems funny to me.

See <http://www.faqs.org/rfcs/rfc2231.html>

The single quotes are delimiters for character-set and language fields
for extended-parameters.

>Fact is in this mail (generated by a recent thunderbird version)
>there is only one single quote in the filename and the function
>fails, see below.
>My fix would be to write "if len(parts) != 3", but I'm interested
>what you say (it fixes this specific problem, I'd say).

Yes it does, but it doesn't fix the general problem because there could
be two single-quote (') characters in a non extended parameter value.

The standard is clear that the single-quote (') character is not
allowed in extended-values, but I think it is OK in non extended
values. The issue in email.Utils is that decode_rfc2231 should only be
called for extended parameters of the form




I.e. only when the '=' is immediately preceded by '*'.

The attached patch.txt file contains a very lightly tested patch that I
think will fix the problem.

Mark Sapiro <msapiro at value.net>       The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch.txt
Url: http://mail.python.org/pipermail/email-sig/attachments/20060707/65c68395/attachment.txt 

More information about the Email-SIG mailing list