The word encoder does not encode all characters:
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'.
Thank you for your report, I just fixed it.
Here is the patch:
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.
You are right.
I have rewritten RFC-2047 encoding, here is a better patch:
Please let me know whether it works for you.
Thanks for the fast and better patch.
There is an other text encoder problem;
mb.setExpeditor(vmime::mailbox(vmime::text("\"Achim Brändt\"", vmime::charsets::UTF_8), "firstname.lastname@example.org"));
From: =?us-ascii?Q?=22Achim?= =?utf-8?Q?Br=C3=A4ndt=22?= <email@example.com>
and this decodes to:
I think it should encode to ("_" for space)
From: =?us-ascii?Q?=22Achim?= =?utf-8?Q?_Br=C3=A4ndt=22?= <firstname.lastname@example.org>
From: =?utf-8?Q?=22Achim_Br=C3=A4ndt=22?= <email@example.com>
There was a bug in text::createFromString(): whitespaces were simply used as word separator, then ignored. Now, whitespace is added to the previously parsed word.
Try with this patch:
Encoding works for me now.
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
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::text gen_text("ü e)");
std::cout << "["<< gen_str << "]"<< std::endl;
I get the string (value of gen_str):
In my opinion there is an additional white space (which is too much)
Using the method decodeAndUnfold one gets the converted string
This happens in following constellations:
"non ascii character" white-space ascii-character !"$%&/()=?,;.:<>|@
I would appreciate, if you could have a look into this issue