From ae10a8a2ecf0f819e10ca4b7074594b7ec621b71 Mon Sep 17 00:00:00 2001 From: Jorg K Date: Fri, 22 Jul 2016 13:07:18 +0200 Subject: [PATCH] Bug 1287126 - restore removal of space stuffing removed in changeset 99eb42a1fd3d. r=mkmelin --- mail/test/mozmill/composition/test-drafts.js | 45 ++++++++++++++++++++ mailnews/mime/src/mimemsg.cpp | 6 +++ 2 files changed, 51 insertions(+) diff --git a/mail/test/mozmill/composition/test-drafts.js b/mail/test/mozmill/composition/test-drafts.js index 3556c46aaf..9ea3a13d52 100644 --- a/mail/test/mozmill/composition/test-drafts.js +++ b/mail/test/mozmill/composition/test-drafts.js @@ -236,6 +236,51 @@ function test_content_language_header() { press_delete(mc); } +/** + * Tests space stuffing of plaintext message. + */ +function test_remove_space_stuffing_format_flowed() { + // Prepare for plaintext email. + let oldHtmlPref = Services.prefs.getBoolPref("mail.identity.default.compose_html"); + Services.prefs.setBoolPref("mail.identity.default.compose_html", false); + + let cwc = open_compose_new_mail(); + + setup_msg_contents(cwc, "test@example.invalid", + "Testing space stuffing in plain text email", + "NoSpace\n OneSpace\n TwoSpaces"); + + cwc.window.SaveAsDraft(); + utils.waitFor(() => !cwc.window.gSaveOperationInProgress && !cwc.window.gWindowLock, + "Saving of draft did not finish"); + wait_for_window_focused(cwc.window); + + close_compose_window(cwc); + + be_in_folder(draftsFolder); + + let draftMsg = select_click_row(0); + + // Wait for the notification with the Edit button. + wait_for_notification_to_show(mc, kBoxId, "draftMsgContent"); + + plan_for_new_window("msgcompose"); + mc.click(mc.eid(kBoxId, {tagName: "button", label: "Edit"})); + cwc = wait_for_compose_window(); + + let bodyText = cwc.e("content-frame").contentDocument + .querySelector("body").innerHTML; + + if (!bodyText.includes("NoSpace
OneSpace
TwoSpaces")) { + assert_true(false, "Something went wrong with space stuffing"); + } + + // Clean up the created draft. + press_delete(mc); + + Services.prefs.setBoolPref("mail.identity.default.compose_html", oldHtmlPref); +} + function teardownModule() { MailServices.accounts.localFoldersServer.rootFolder .propagateDelete(draftsFolder, true, null); diff --git a/mailnews/mime/src/mimemsg.cpp b/mailnews/mime/src/mimemsg.cpp index 2e8ff0ce08..add30543de 100644 --- a/mailnews/mime/src/mimemsg.cpp +++ b/mailnews/mime/src/mimemsg.cpp @@ -182,6 +182,12 @@ MimeMessage_parse_line (const char *aLine, int32_t aLength, MimeObject *obj) // line in mimeInlineTextPlainFlowedClass. if (mime_typep(kid, (MimeObjectClass *)&mimeInlineTextPlainFlowedClass)) { + // Remove any stuffed space. + if (length > 0 && ' ' == *line) + { + line++; + length--; + } return kid->clazz->parse_line (line, length, kid); } else