Closed Bug 1959301 Opened 12 days ago Closed 11 days ago

mailnews/base/test/unit/test_saveAs.js - testing save as .txt (and .html) fails if message body contains CRLFs.

Categories

(MailNews Core :: Testing Infrastructure, defect)

defect

Tracking

(Not tracked)

RESOLVED FIXED
139 Branch

People

(Reporter: benc, Assigned: benc)

References

Details

Attachments

(1 file)

The current save as .txt unit test works, but only because the test message has no line endings in the body.
When nsMessenger.saveAs() is used to save out a file with a .txt extension, it formats the message using (presumably) native line endings (\n on unix, I assume \r\n on windows?).
So on a unix system the CRLFs are saved as plain LFs.

However, the test checks that the originally-generated message body is include in the saved file, but this fails if the original message body has CRLFs in it (which it should! it's a line-oriented format).

The assert here fails:
https://searchfox.org/comm-central/rev/59abd448822dcbee815be6d599b19108d0d42c0b/mailnews/base/test/unit/test_saveAs.js#158

Out of interest if you right click on a message and "Save As" to an .eml file, it comes out like this (with CRLF line endings):

In-Reply-To: <271989@yahoo.com>
References: <272292@gmail.com> <271989@yahoo.com>
Subject: Re: Networked dynamic workforce
From: braxton@example.org
Message-ID: <318069@yahoo.com>
Date: Sun, 13 Jul 1997 18:55:00 +0000

illum perferendis saepe consequatur ducimus minima accusamus.
est et sapiente quam quos nesciunt at.
omnis commodi suscipit eligendi repellat possimus et.
doloribus molestiae autem unde qui ut est sapiente nostrum.
sunt consectetur ratione perspiciatis exercitationem et et.
labore ut explicabo id hic sint suscipit.

The same message saved out to a .txt file comes out (with LF line endings) as:

 Re: Networked dynamic workforce
Subject:
Re: Networked dynamic workforce
From:
braxton@example.org
Date:
14/07/1997, 06:55

illum perferendis saepe consequatur ducimus minima accusamus.
est et sapiente quam quos nesciunt at.
omnis commodi suscipit eligendi repellat possimus et.
doloribus molestiae autem unde qui ut est sapiente nostrum.
sunt consectetur ratione perspiciatis exercitationem et et.
labore ut explicabo id hic sint suscipit.

note the odd indent of subject on first line, and the extra blank line at the end.

Feels like it could be made prettier...

Summary: mailnews/base/test/unit/test_saveAs.js - testing save as .txt fails if message body contains CRLFs. → mailnews/base/test/unit/test_saveAs.js - testing save as .txt (and .html) fails if message body contains CRLFs.
Assignee: nobody → benc
Status: NEW → ASSIGNED

Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/47b5920e3a4a
Allow for platform EOL differences in test_saveAs.js .txt and .html export. r=mkmelin

Status: ASSIGNED → RESOLVED
Closed: 11 days ago
Resolution: --- → FIXED
Target Milestone: --- → 139 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: