compose.beginNew() API turns insignificant newlines in HTML body into <br>
Categories
(Thunderbird :: Add-Ons: Extensions API, defect)
Tracking
(thunderbird_esr78 affected, thunderbird89 affected)
People
(Reporter: addons, Assigned: TbSync)
Details
Attachments
(2 files)
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36 Edg/88.0.705.63
Steps to reproduce:
When the HTML passed to compose.beginNew()
contains insignificant newlines in HTML body, these are turned into into <br> in the compose window.
Actual results:
To many empty lines displayed in the compose window.
Expected results:
Insignificant newlines should have been ignored.
Workaround: Call compose.beginNew()
only with an object containing isPlainText
, then use compose.setComposeDetails()
.
Comment 2•3 years ago
|
||
Please can you clarify what you mean in terms of the text input and output and what you see? e.g. use three backticks for fixed width formatting, and provide an example like this:
foo
bar
is transformed into
<p>foo</p>
<p>bar</p>
This is passed into console.log(body); compose.beginNew(null, body)
:
body: "<html><head>\n\n \n<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">\n\n </head><body>\n \n<p><font face=\"monospace\">klkläöüöäüä</font><br>\n </p>\n\n \n\n\n</body></html>\n\n\n"
IOW:
Content-Type: text/html; charset=windows-1252
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head><body>
<p><font face="monospace">klkläöüöäüä</font><br>
</p>
</body></html>
The result in the compose window looking with ThunderHTMLedit is:
<!DOCTYPE html><html>
<head>
<br>
<br>
<br>
<meta http-equiv="content-type" content="text/html; charset=">
<br>
<br>
</head>
<body>
<br>
<br>
<p><font face="monospace">klkläöüöäüä</font><br>
<br>
</p>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</body>
</html>
The two <br>s after the <body> tag are visible.
I looked at the code myself and it's rather peculiar that this happens since compose.beginNew()
also calls compose.setComposeDetails()
here:
https://searchfox.org/comm-central/rev/de53be93b92dae5f76dd837ab07b5852525b4dbc/mail/components/extensions/parent/ext-compose.js#170
In the end it comes down to editor.rebuildDocumentFromSource(newValues.body);
https://searchfox.org/comm-central/rev/de53be93b92dae5f76dd837ab07b5852525b4dbc/mail/components/compose/content/MsgComposeCommands.js#4397
Could it be that the editor needs to be set to plaint/html before the first call?
Mark, are you using the function and is it working OK for you?
Sorry, the Content-Type: text/html; charset=windows-1252 was a copy/paste error from the EML file, it's not part of the HTML passed into the function as the console output showed.
Assignee | ||
Comment 5•3 years ago
|
||
Reproducible with the attached add-on.
Assignee | ||
Comment 6•3 years ago
•
|
||
While working on fixing this I discovered two more bugs, which I will fix in here as well:
- beginReply ignored details.body and details.plainTextBody (unnoticed as not tested)
- the compose-editor-ready event is send to early
Assignee | ||
Comment 7•3 years ago
|
||
Depends on D114679
Updated•3 years ago
|
Assignee | ||
Updated•3 years ago
|
Updated•3 years ago
|
Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/766abe1bd619
Fix wrongly inserted br tags in body and let beginReply no longer ignore body completely. r=mkmelin
Comment 9•3 years ago
|
||
Uplift/wontfix for 78?
Assignee | ||
Comment 10•3 years ago
|
||
If try run is clean:
https://treeherder.mozilla.org/#/jobs?repo=try-comm-central&revision=255e1c23d714a5ceed7f5b5f40e1454e3d024850
If this bug is backported, than we should also backport the one which fixed the subject. Let us wait and see what the try run is doing.
Comment 11•3 years ago
|
||
Needs a new try run.
Description
•