Reset line length after encoding a hard line break in QP encoding.

This commit is contained in:
Vincent Richard 2014-01-14 08:18:24 +01:00
parent 78cc6e5de1
commit fe43da096f
2 changed files with 41 additions and 0 deletions

View File

@ -299,6 +299,9 @@ size_t qpEncoder::encode(utility::inputStream& in,
{ {
outBuffer[outBufferPos++] = c; outBuffer[outBufferPos++] = c;
++curCol; ++curCol;
if (c == 10)
curCol = 0; // reset current line length
} }
// Binary data // Binary data
else else

View File

@ -31,6 +31,8 @@ VMIME_TEST_SUITE_BEGIN(qpEncoderTest)
VMIME_TEST_LIST_BEGIN VMIME_TEST_LIST_BEGIN
VMIME_TEST(testQuotedPrintable) VMIME_TEST(testQuotedPrintable)
VMIME_TEST(testQuotedPrintable_SoftLineBreaks) VMIME_TEST(testQuotedPrintable_SoftLineBreaks)
VMIME_TEST(testQuotedPrintable_HardLineBreakEncode)
VMIME_TEST(testQuotedPrintable_HardLineBreakDecode)
VMIME_TEST(testQuotedPrintable_CRLF) VMIME_TEST(testQuotedPrintable_CRLF)
VMIME_TEST(testQuotedPrintable_RFC2047) VMIME_TEST(testQuotedPrintable_RFC2047)
VMIME_TEST_LIST_END VMIME_TEST_LIST_END
@ -157,6 +159,42 @@ VMIME_TEST_SUITE_BEGIN(qpEncoderTest)
"to come to the aid of their country.", 15)); "to come to the aid of their country.", 15));
} }
void testQuotedPrintable_HardLineBreakEncode()
{
const std::string data =
"If you believe that truth=beauty,"
" then surely mathematics\r\nis the most"
" beautiful branch of philosophy.";
const std::string expected =
"If you believe that truth=3Dbeauty=\r\n"
", then surely mathematics\r\n"
"is the most beautiful branch of ph=\r\n"
"ilosophy.";
vmime::propertySet encProps;
encProps["text"] = true;
VASSERT_EQ("1", expected, encode("quoted-printable", data, 35, encProps));
}
void testQuotedPrintable_HardLineBreakDecode()
{
const std::string expected =
"If you believe that truth=beauty,"
" then surely mathematics\r\nis the most"
" beautiful branch of philosophy.";
const std::string data =
"If you believe that truth=3Dbeauty=\r\n"
", then surely mathematics\r\n"
"is the most beautiful branch of ph=\r\n"
"ilosophy.";
VASSERT_EQ("1", expected, decode("quoted-printable", data, 35));
}
/** In text mode, ensure line breaks in QP-encoded text are represented /** In text mode, ensure line breaks in QP-encoded text are represented
* by a CRLF sequence, as per RFC-2047/6.7(4). */ * by a CRLF sequence, as per RFC-2047/6.7(4). */
void testQuotedPrintable_CRLF() void testQuotedPrintable_CRLF()