Error in encoded-words (RFC 2047)

A. Brandt
2010-10-12
2013-04-25
  • A. Brandt
    A. Brandt
    2010-10-12

    The word encoder does not encode all characters:

    Subject: =?UTF-8?Q?"=C3=9Cml=C3=A4ute"?=

    should be:

    Subject: =?UTF-8?Q?=22=C3=9Cml=C3=A4ute=22?=

    The RFC (http://tools.ietf.org/html/rfc2047#section-5) says:

        In this case the set of characters that may be used in a "Q"-encoded
        'encoded-word' is restricted to: <upper and lower case ASCII
        letters, decimal digits, "!", "*", "+", "-", "/", "=", and "_"
        (underscore, ASCII 95.)>.  An 'encoded-word' that appears within a
        'phrase' MUST be separated from any adjacent 'word', 'text' or
        'special' by 'linear-white-space'.

    The "-character is not allowed in an 'encoded-word'.

     
  • A. Brandt
    A. Brandt
    2010-10-12

    Thanks for the fast patch.

    But I think there is more to do.:
    - The encode() function in qpEncoder.cpp has to encode more special characters like '§$%&'.
    - The "outputCount" in function getNextChunk() in wordEncode.cpp is wrong for this special characters.

    Best Regards,
    Achim

     
  • A. Brandt
    A. Brandt
    2010-10-12

    Thanks for the fast and better patch.

    Best Regards,
    Achim

     
  • A. Brandt
    A. Brandt
    2010-10-12

    There is an other text encoder problem;

        vmime::messageBuilder mb;
        mb.setExpeditor(vmime::mailbox(vmime::text("\"Achim Brändt\"", vmime::charsets::UTF_8), "me@vmime.org"));

    encodes to:

    From: =?us-ascii?Q?=22Achim?= =?utf-8?Q?Br=C3=A4ndt=22?= <me@vmime.org>

    and this decodes to:

    "AchimBrändt" me@vmime.org

    I think it should encode to ("_" for space)
    From: =?us-ascii?Q?=22Achim?= =?utf-8?Q?_Br=C3=A4ndt=22?= <me@vmime.org>
    or
    From: =?utf-8?Q?=22Achim_Br=C3=A4ndt=22?= <me@vmime.org>

     
  • A. Brandt
    A. Brandt
    2010-10-13

    Thanks,
    Encoding works for me now.

    Best Regards
    Achim

     
  • Hello,

    I am trying to generate mails with vmime. Using the function
    vmime::text::newFromString for assigning values with no ascii
    characters to headerField, I have observed that the new strings contain
    additional white-spaces.
    Sample: Input String 'ü e)' . The Output of vmime::text::newFromString
    is 'ü  e)'. It contains an additional white space. I could reproduce
    this behaviour without  vmime::text::newFromString too, with following code

        vmime::string gen_str;
        vmime::utility::outputStreamStringAdapter os1(gen_str);
        vmime::text gen_text("ü e)");
        gen_text.generate(os1);
        std::cout << "["<< gen_str << "]"<< std::endl;
    

    I get the string (value of gen_str):

    =?UTF-8?B?w7wg?= e)
    

    In my opinion there is an additional white space (which is too much)

    Using the method decodeAndUnfold one gets the converted string

    ü  e)
    

    Resume:

    Input string

    'ü e)'
    

    Converted string

    'ü  e)'
    

    This happens  in following constellations:
    "non ascii character" white-space ascii-character !"$%&/()=?,;.:<>|@

    I would appreciate, if you could have a look into this issue

    Kind regards
    Esteban Lombeyda