Bug 1702197 - Prevent using quoted-printable for format=flowed message. r=mkmelin
Also fix removing stuffed space in format=flowed message. Differential Revision: https://phabricator.services.mozilla.com/D112679 --HG-- extra : amend_source : b26cbdcfc3ca9bb8232a49972d6f7191b043597a
This commit is contained in:
Родитель
231b442a31
Коммит
7554b6802c
|
@ -94,8 +94,18 @@ class MimeEncoder {
|
|||
(strictlyMime && this._unPrintableCount) ||
|
||||
this._nullCount
|
||||
) {
|
||||
if (
|
||||
this._isMainBody &&
|
||||
this._contentType == "text/plain" &&
|
||||
// From rfc3676#section-4.2, Quoted-Printable encoding SHOULD NOT be
|
||||
// used with Format=Flowed unless absolutely necessary.
|
||||
Services.prefs.getBoolPref("mailnews.send_plaintext_flowed")
|
||||
) {
|
||||
needsB64 = true;
|
||||
} else {
|
||||
encodeP = true;
|
||||
}
|
||||
}
|
||||
|
||||
// MIME requires a special case that these types never be encoded.
|
||||
if (
|
||||
|
@ -408,12 +418,7 @@ class MimeEncoder {
|
|||
|
||||
if (currentColumn >= 73) {
|
||||
// Soft line break for readability
|
||||
if (i + 1 < this._bodySize && this._body[i + 1] == " ") {
|
||||
out += "=20\r\n";
|
||||
i++;
|
||||
} else {
|
||||
out += "=\r\n";
|
||||
}
|
||||
white = false;
|
||||
currentColumn = 0;
|
||||
}
|
||||
|
|
|
@ -62,13 +62,12 @@ add_task(async function testQP() {
|
|||
"QP for non-ascii should work"
|
||||
);
|
||||
|
||||
// Bug 1689804 - Avoid a QP soft line break before a space.
|
||||
// Test leading space is preserved.
|
||||
|
||||
fields = new CompFields();
|
||||
fields.forceMsgEncoding = true;
|
||||
fields.to = "Nobody <nobody@tinderbox.invalid>";
|
||||
fields.subject =
|
||||
"Bug 1689804 - Save a space to the previous line on a quoted printable soft line break.";
|
||||
fields.subject = "Leading space is valid in a quoted printable message";
|
||||
fields.body = "123456789" + " 123456789".repeat(6) + "1234 56789";
|
||||
await richCreateMessage(fields, [], identity);
|
||||
|
||||
|
@ -81,7 +80,49 @@ add_task(async function testQP() {
|
|||
|
||||
Assert.equal(
|
||||
body.trimRight("\r\n"),
|
||||
"123456789 123456789 123456789 123456789 123456789 123456789 1234567891234=20\r\n56789"
|
||||
"123456789 123456789 123456789 123456789 123456789 123456789 1234567891234=\r\n 56789"
|
||||
);
|
||||
|
||||
Services.prefs.clearUserPref("mail.strictly_mime");
|
||||
});
|
||||
|
||||
/**
|
||||
* Test QP is not used together with format=flowed.
|
||||
*/
|
||||
add_task(async function testNoQPWithFormatFlowed() {
|
||||
if (!Services.prefs.getBoolPref("mailnews.send.jsmodule")) {
|
||||
return;
|
||||
}
|
||||
// Together with fields.forceMsgEncoding, force quote-printable encoding.
|
||||
Services.prefs.setBoolPref("mail.strictly_mime", true);
|
||||
|
||||
let identity = getSmtpIdentity(
|
||||
"from@tinderbox.invalid",
|
||||
getBasicSmtpServer()
|
||||
);
|
||||
let fields = Cc[
|
||||
"@mozilla.org/messengercompose/composefields;1"
|
||||
].createInstance(Ci.nsIMsgCompFields);
|
||||
fields.forceMsgEncoding = true;
|
||||
fields.forcePlainText = true;
|
||||
fields.to = "Nobody <nobody@tinderbox.invalid>";
|
||||
fields.subject = "Test QP encoding for trailing whitespace";
|
||||
fields.body = "A line with trailing whitespace\t ";
|
||||
await richCreateMessage(fields, [], identity);
|
||||
|
||||
let msgData = mailTestUtils.loadMessageToString(
|
||||
gDraftFolder,
|
||||
mailTestUtils.firstMsgHdr(gDraftFolder)
|
||||
);
|
||||
Assert.ok(
|
||||
msgData.includes(
|
||||
"Content-Type: text/plain; charset=UTF-8; format=flowed\r\nContent-Transfer-Encoding: base64"
|
||||
),
|
||||
"format=flowed should be used"
|
||||
);
|
||||
Assert.ok(
|
||||
!msgData.includes("quoted-printable"),
|
||||
"quoted-printable should not be used"
|
||||
);
|
||||
|
||||
Services.prefs.clearUserPref("mail.strictly_mime");
|
||||
|
|
|
@ -966,11 +966,6 @@ nsresult QPEncoder::Write(const char* buffer, int32_t size) {
|
|||
if (mCurrentColumn >= 73) // Soft line break for readability
|
||||
{
|
||||
*out++ = '=';
|
||||
if (in + 1 < end && in[1] == ' ') {
|
||||
in++;
|
||||
*out++ = '2';
|
||||
*out++ = '0';
|
||||
}
|
||||
*out++ = '\r';
|
||||
*out++ = '\n';
|
||||
|
||||
|
|
|
@ -148,15 +148,6 @@ static int MimeMessage_parse_line(const char* aLine, int32_t aLength,
|
|||
*/
|
||||
nl = (length > 0 && (line[length - 1] == '\r' || line[length - 1] == '\n'));
|
||||
|
||||
if (!mime_typep(kid, (MimeObjectClass*)&mimeMessageClass) && obj->options &&
|
||||
!obj->options->is_multipart_msg && !obj->options->decrypt_p &&
|
||||
mime_typep(kid, (MimeObjectClass*)&mimeInlineTextPlainFlowedClass)) {
|
||||
// Remove any stuffed space.
|
||||
if (length > 0 && ' ' == *line) {
|
||||
line++;
|
||||
length--;
|
||||
}
|
||||
}
|
||||
#ifdef MIME_DRAFTS
|
||||
if (!mime_typep(kid, (MimeObjectClass*)&mimeMessageClass) && obj->options &&
|
||||
obj->options->decompose_file_p && !obj->options->is_multipart_msg &&
|
||||
|
|
|
@ -277,7 +277,9 @@ static int MimeInlineTextPlainFlowed_parse_line(const char* aLine,
|
|||
const char* linep = real_line.BeginReading();
|
||||
// Space stuffed?
|
||||
if (' ' == *linep) {
|
||||
line++;
|
||||
linep++;
|
||||
length--;
|
||||
} else {
|
||||
// count '>':s before the first non-'>'
|
||||
while ('>' == *linep) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче