#238 Fixed whitespace between encoded words
This commit is contained in:
parent
9a10a839ec
commit
5c00f7867a
@ -596,7 +596,7 @@ void word::generate(
|
||||
} else {
|
||||
|
||||
if (!state->isFirstWord &&
|
||||
state->prevWordIsEncoded &&
|
||||
(state->prevWordIsEncoded || ctx.getInternationalizedEmailSupport()) &&
|
||||
!state->lastCharIsSpace &&
|
||||
!parserHelpers::isSpace(*curLineStart)) {
|
||||
|
||||
|
@ -59,6 +59,7 @@ VMIME_TEST_SUITE_BEGIN(textTest)
|
||||
VMIME_TEST(testInternationalizedEmail_UTF8)
|
||||
VMIME_TEST(testInternationalizedEmail_nonUTF8)
|
||||
VMIME_TEST(testInternationalizedEmail_folding)
|
||||
VMIME_TEST(testInternationalizedEmail_whitespace)
|
||||
|
||||
VMIME_TEST(testWronglyPaddedB64Words)
|
||||
VMIME_TEST(testFixBrokenWords)
|
||||
@ -694,6 +695,90 @@ VMIME_TEST_SUITE_BEGIN(textTest)
|
||||
);
|
||||
}
|
||||
|
||||
void testInternationalizedEmail_whitespace() {
|
||||
|
||||
// Sanity checks for running this test
|
||||
{
|
||||
vmime::text t;
|
||||
t.parse("=?utf-8?Q?Adquisi=C3=B3n?= de Laptop y celular");
|
||||
|
||||
VASSERT_EQ("parse", "Adquisión de Laptop y celular", t.getWholeBuffer());
|
||||
}
|
||||
|
||||
{
|
||||
vmime::text t("Adquisi\xc3\xb3n de Laptop y celular", vmime::charset("UTF-8"));
|
||||
|
||||
VASSERT_EQ("generate", "=?UTF-8?Q?Adquisi=C3=B3n?= de Laptop y celular", t.generate());
|
||||
}
|
||||
|
||||
// Ensure a whitespace is added between encoded words in intl email support enabled
|
||||
{
|
||||
vmime::text t;
|
||||
t.parse("=?utf-8?Q?Adquisi=C3=B3n?= de Laptop y celular");
|
||||
|
||||
std::ostringstream oss;
|
||||
vmime::utility::outputStreamAdapter ossAdapter(oss);
|
||||
vmime::generationContext gctx(vmime::generationContext::getDefaultContext());
|
||||
gctx.setInternationalizedEmailSupport(true);
|
||||
t.generate(gctx, ossAdapter);
|
||||
|
||||
VASSERT_EQ("generate", "Adquisi\xc3\xb3n de Laptop y celular", oss.str());
|
||||
}
|
||||
|
||||
{
|
||||
vmime::text t;
|
||||
t.parse("=?utf-8?Q?Adquisi=C3=B3n?= de Laptop =?utf-8?Q?y?= celular");
|
||||
|
||||
std::ostringstream oss;
|
||||
vmime::utility::outputStreamAdapter ossAdapter(oss);
|
||||
vmime::generationContext gctx(vmime::generationContext::getDefaultContext());
|
||||
gctx.setInternationalizedEmailSupport(true);
|
||||
t.generate(gctx, ossAdapter);
|
||||
|
||||
VASSERT_EQ("generate", "Adquisi\xc3\xb3n de Laptop y celular", oss.str());
|
||||
}
|
||||
|
||||
{
|
||||
vmime::text t;
|
||||
t.parse("=?utf-8?Q?Adquisi=C3=B3n?= de Laptop =?utf-8?Q?y_celular?=");
|
||||
|
||||
std::ostringstream oss;
|
||||
vmime::utility::outputStreamAdapter ossAdapter(oss);
|
||||
vmime::generationContext gctx(vmime::generationContext::getDefaultContext());
|
||||
gctx.setInternationalizedEmailSupport(true);
|
||||
t.generate(gctx, ossAdapter);
|
||||
|
||||
VASSERT_EQ("generate", "Adquisi\xc3\xb3n de Laptop y celular", oss.str());
|
||||
}
|
||||
|
||||
// Ensure no whitespace is added with non-encoded words
|
||||
{
|
||||
vmime::text t;
|
||||
t.parse("Laptop y celular");
|
||||
|
||||
std::ostringstream oss;
|
||||
vmime::utility::outputStreamAdapter ossAdapter(oss);
|
||||
vmime::generationContext gctx(vmime::generationContext::getDefaultContext());
|
||||
gctx.setInternationalizedEmailSupport(true);
|
||||
t.generate(gctx, ossAdapter);
|
||||
|
||||
VASSERT_EQ("generate", "Laptop y celular", oss.str());
|
||||
}
|
||||
|
||||
{
|
||||
vmime::text t;
|
||||
t.parse("=?utf-8?Q?Laptop_y_celular?=");
|
||||
|
||||
std::ostringstream oss;
|
||||
vmime::utility::outputStreamAdapter ossAdapter(oss);
|
||||
vmime::generationContext gctx(vmime::generationContext::getDefaultContext());
|
||||
gctx.setInternationalizedEmailSupport(true);
|
||||
t.generate(gctx, ossAdapter);
|
||||
|
||||
VASSERT_EQ("generate", "Laptop y celular", oss.str());
|
||||
}
|
||||
}
|
||||
|
||||
void testWronglyPaddedB64Words() {
|
||||
|
||||
vmime::text outText;
|
||||
|
Loading…
Reference in New Issue
Block a user