Error in encoded-words (RFC 2047)

A. Brandt
  • A. Brandt
    A. Brandt

    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 ( 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

    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,

  • A. Brandt
    A. Brandt

    Thanks for the fast and better patch.

    Best Regards,

  • A. Brandt
    A. Brandt

    There is an other text encoder problem;

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

    encodes to:

    From: =?us-ascii?Q?=22Achim?= =?utf-8?Q?Br=C3=A4ndt=22?= <>

    and this decodes to:


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

  • A. Brandt
    A. Brandt

    Encoding works for me now.

    Best Regards

  • 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)");
        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)


    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