Re: [gmime-devel] Problems with quoted-printable encoding

On 09/14/2010 09:30 AM, Damian Pietras wrote:
> I'm having problems with quoted-printable encoding. I'm doing a possible
> stupid thing: attaching a binary file (empty .doc document) as a MIME
> part using the quoted-printable encoding. The problem is that if the
> last byte in the file is binary, it's encoded value is appended without
> the '=' character at end of line. The decoder doesn't see '=' at the end
> of last line and treats "\r\n" as part of data.
> I think the problem is in g_mime_encoding_quoted_encode_close:
> if (last != -1) {
>             /* space/tab must be encoded if its the last character on
>                the line */
>             if (is_qpsafe (last) && !is_blank (last)) {
>                     *outptr++ = last;
>             } else {
>                     *outptr++ = '=';
>                     *outptr++ = tohex[(last >> 4) & 0xf];
>                     *outptr++ = tohex[last & 0xf];
>             }
>     }
> *outptr++ = '\n';
> I would insert "=\n" instead of '\n' alone. This fixes my case.

Not only are you right about needing to add the = when the last
character is binary, but this is just good practice anyways. Without the
=, the decoder will interpret the \n as if it were actually /meant/ to
be part of its input and thus it adds a new \n to the output, and so
each encode/decode pair will effectively add a new \n to the result.

I'll commit my path when I get home from work tonight and get a chance
to play with a few things.

Thanks again,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]