Go to file
Jan Engelhardt d296c2d1d5
vmime: prevent loss of a space during text::createFromString (#306)
```
mailbox(text("Test München West", charsets::UTF_8), "a@b.de").generate();
```

produces

```
=?us-ascii?Q?Test_?= =?utf-8?Q?M=C3=BCnchen?= =?us-ascii?Q?West?= <test@example.com>
```

The first space between ``Test`` and ``München`` is encoded as an
underscore along with the first word: ``Test_``. The second space
between ``München`` and ``West`` is encoded with neither of the two
words and thus lost. Decoding the text results in ``Test
MünchenWest`` instead of ``Test München West``.

This is caused by how ``vmime::text::createFromString()`` handles
transitions between 7-bit and 8-bit words: If an 8-bit word follows a
7-bit word, a space is appended to the previous word. The opposite
case of a 7-bit word following an 8-bit word *misses* this behaviour.

When one fixes this problem, a follow-up issue appears:

``text::createFromString("a b\xFFc d")`` tokenizes the input into
``m_words={word("a "), word("b\xFFc ", utf8), word("d")}``. This
"right-side alignment" nature of the whitespace is a problem for
word::generate():

As per RFC 2047, spaces between adjacent encoded words are just
separators but not meant to be displayed. A space between an encoded
word and a regular ASCII text is not just a separator but also meant
to be displayed.

When word::generate() outputs the b-word, it would have to strip one
space, but only when there is a transition from encoded-word to
unencoded word. word::generate() does not know whether d will be
encoded or unencoded.

The idea now is that we could change the tokenization of
``text::createFromString`` such that whitespace is at the *start* of
words rather than at the end. With that, word::generate() need not
know anything about the next word, but rather only the *previous*
one.

Thus, in this patch,

1. The tokenization of ``text::createFromString`` is changed to
   left-align spaces and the function is fixed to account for
   the missing space on transition.
2. ``word::generate`` learns how to steal a space character.
3. Testcases are adjusted to account for the shifted
   position of the space.

Fixes: #283, #284

Co-authored-by: Vincent Richard <vincent@vincent-richard.net>
2024-05-21 15:55:06 +02:00
cmake Build: add FreeBSD & libc++ compilation support (#288) 2023-12-31 15:22:36 +01:00
contrib Issue #126: even more warnings fixed. 2016-03-24 08:00:34 +01:00
doc/book Code style and clarity. 2018-09-05 23:54:48 +02:00
examples Code style and clarity. 2018-09-05 23:54:48 +02:00
src/vmime vmime: prevent loss of a space during text::createFromString (#306) 2024-05-21 15:55:06 +02:00
tests vmime: prevent loss of a space during text::createFromString (#306) 2024-05-21 15:55:06 +02:00
.gitignore Merged source and header files in directory structure. Got rid of SConstruct build. 2013-12-29 10:02:12 +01:00
.travis.yml Fixed location of config and lib export include files. 2016-03-25 08:25:43 +01:00
AUTHORS Issue #36: added support for wildcard in Common Name when verifying host name (thanks to Anthony Dervish). 2013-04-26 20:58:04 +02:00
CMakeLists.txt Fixed confusing source/bin dirs in makefile. (#291) 2024-01-12 13:36:00 +01:00
COPYING Relicensed VMime under the GNU GPL version 3. Changed copyright year to 2009. 2009-09-06 12:02:10 +00:00
COPYING.OpenSSL #236 OpenSSL license exception 2020-02-14 22:25:58 +01:00
Doxyfile.in Define "VMIME_HAVE_FILESYSTEM_FEATURES" to generate doc for classes related to files (eg. fileAttachment). 2013-05-18 08:43:39 +02:00
HACKING Code style and clarity. 2018-09-05 23:54:48 +02:00
NEWS Initial import. 2004-10-05 10:28:21 +00:00
README Updated README. 2012-04-05 12:34:51 +02:00
README.autotools Migrated build system to CMake. Conditional file compilation. Automatic selection of platform handler. 2012-11-01 18:20:06 +01:00
test-outsourced-build.sh Use string option instead of mutually exclusive bool options for charset and TLS library. 2014-05-27 21:59:37 +02:00
vmime.pc.in Pkg-config file changed back to "vmime.pc" (fixed issue #35). 2013-03-24 20:28:36 +01:00

VMime is a powerful C++ class library for working with RFC-822 and MIME messages
and Internet messaging services like IMAP, POP or SMTP.

With VMime you can parse, generate and modify messages, and also connect to store
and transport services to receive or send messages over the Internet. The library
offers all the features to build a complete mail client.

Key Features
------------

* it is free software! GNU GPL license (Commercial licenses available!)
* fully RFC-compliant implementation
* object-oriented and modular design
* very easy-to-use (intuitive design)
* well documented code
* very high reliability
* maximum portability

Features Overview
-----------------

* RFC-2822 and multipart messages
* aggregate documents and embedded objects
* 8-bit MIME and encoded word extensions
* full support for attachments
* POP3, IMAP, SMTP, maildir and sendmail
* SSL/TLS security layer and X.509 certificates (using GNU TLS)
* SASL authentication (using GNU SASL)