Bug 1614796 - Body search: Strip soft line breaks in QP parts when assembling HTML body. r=benc
This commit is contained in:
Родитель
9cf197d9e3
Коммит
8ca5007982
|
@ -274,7 +274,7 @@ int32_t nsMsgBodyHandler::ApplyTransformations(const nsCString &line,
|
|||
eatThisLine = true;
|
||||
} else {
|
||||
// It is wrong to call ApplyTransformations() here since this will
|
||||
// lead to the buffer being doubled-up at |buf.Append(line.get());|
|
||||
// lead to the buffer being doubled-up at |buf.Append(line);|
|
||||
// below. ApplyTransformations(buf, buf.Length(), eatThisLine, buf);
|
||||
// Avoid spurious failures
|
||||
eatThisLine = false;
|
||||
|
@ -313,9 +313,18 @@ int32_t nsMsgBodyHandler::ApplyTransformations(const nsCString &line,
|
|||
|
||||
// Accumulate base64 parts and HTML parts for later decoding or tag stripping.
|
||||
if (m_base64part || m_partIsHtml) {
|
||||
if (m_partIsHtml && !m_base64part) // Replace newline in HTML with a space.
|
||||
buf.Append(' ');
|
||||
buf.Append(line.get());
|
||||
if (m_partIsHtml && !m_base64part) {
|
||||
size_t bufLength = buf.Length();
|
||||
if (!m_partIsQP || bufLength == 0 ||
|
||||
!StringEndsWith(buf, NS_LITERAL_CSTRING("="))) {
|
||||
// Replace newline in HTML with a space.
|
||||
buf.Append(' ');
|
||||
} else {
|
||||
// Strip the soft line break.
|
||||
buf.SetLength(bufLength - 1);
|
||||
}
|
||||
}
|
||||
buf.Append(line);
|
||||
eatThisLine = true;
|
||||
return buf.Length();
|
||||
}
|
||||
|
|
|
@ -859,7 +859,7 @@ nsresult nsMsgSearchTerm::MatchBody(nsIMsgSearchScopeTerm *scope,
|
|||
compare.Append(buf);
|
||||
// If this line ends with a soft line break, loop around
|
||||
// and get the next line before looking for the search string.
|
||||
// This assumes the message can't end on a QP soft-line break.
|
||||
// This assumes the message can't end on a QP soft line break.
|
||||
// That seems like a pretty safe assumption.
|
||||
if (softLineBreak) continue;
|
||||
if (!compare.IsEmpty()) {
|
||||
|
|
|
@ -132,6 +132,9 @@ var Tests = [
|
|||
// Message 22 contains Καλημέρα (good morning in Greek).
|
||||
{ value: "Καλημέρα", op: Contains, count: 1 },
|
||||
|
||||
// Messages 21, 23 and 24 contain "softbreak" broken by a soft line break.
|
||||
{ value: "softbreak", op: Contains, count: 3 },
|
||||
|
||||
// Messages 16, 17, 18, 20 contain "hähä" in the plaintext part.
|
||||
{ value: "hähä", op: Contains, count: 4 },
|
||||
|
||||
|
|
|
@ -11,4 +11,6 @@ Content-Transfer-Encoding: quoted-printable
|
|||
Content-Language: en-GB
|
||||
|
||||
Search for h=C3=B6h=C3=B6
|
||||
Test that we ignore a soft=
|
||||
break correctly.
|
||||
|
||||
|
|
|
@ -10,5 +10,9 @@ Content-Type: text/html; charset="utf-8"; format=flowed
|
|||
Content-Transfer-Encoding: quoted-printable
|
||||
Content-Language: en-GB
|
||||
|
||||
<body>Search for <b>h=C3=B6h=C3=B6</b></body>
|
||||
<body>Search for <b>h=C3=B6h=C3=B6</b>
|
||||
Test that we assemble HTML bodies correctly when there is a
|
||||
<a href=3D"https://www.example.com">soft=
|
||||
break</a> involved.
|
||||
</body>
|
||||
|
||||
|
|
|
@ -15,7 +15,10 @@ This is a multi-part message in MIME format.
|
|||
Content-Type: text/html; charset="utf-8"; format=flowed
|
||||
Content-Transfer-Encoding: quoted-printable
|
||||
|
||||
<body>Search for <b>h=C3=B6h=C3=B6</b></body>
|
||||
<body>Search for <b>h=C3=B6h=C3=B6</b>
|
||||
Test that we ignore a soft=
|
||||
break correctly.
|
||||
</body>
|
||||
|
||||
--------------BC006DD22051247571F398E0
|
||||
Content-Type: image/png;
|
||||
|
|
Загрузка…
Ссылка в новой задаче