Bug 1672407 Comment 2 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

It appears to happen during setting the content already. `SetComposeDetails()` eventually calls `editor.insertText()` . One can also execute the following from the console in a compose window:
```
window.GetCurrentEditor().insertText("123\r\n123\r\n");
```
The content "looks" right, but if copy-pasted into an editor which is capable of showing line endings, one can see, that the extra \r\n are already there. But it appears the editor collapses \r\n\r\n into a single linebreak. This

```
window.GetCurrentEditor().insertText("123\n123\n");
```
works correct (and gives \r\n per line break).


@Magnus: The editor code is in M-C and they explicitly have this:

>  // Note that we don't need to replace native line breaks with XP line breaks
>  // here because Chrome does not do it.

https://searchfox.org/comm-central/source/mozilla/editor/libeditor/EditorBase.cpp#4985-4986

Instead of changing anything there (which I do not think is a good idea), I would simply sanitize the input for the WebExtension compose.setComposeDetails and replace any \r\n by \n? This is also done in other code paths by the composer directly (https://searchfox.org/comm-central/source/mailnews/compose/src/nsMsgCompose.cpp#2717) but not in this case. Ok?
It appears to happen during setting the content already. `SetComposeDetails()` eventually calls `editor.insertText()` . One can also execute the following from the console in a compose window:
```
window.GetCurrentEditor().insertText("123\r\n123\r\n");
```
The content "looks" right, but if copy-pasted into an editor which is capable of showing line endings, one can see, that the extra \r\n are already there. But it appears the editor collapses \r\n\r\n into a single linebreak. This

```
window.GetCurrentEditor().insertText("123\n123\n");
```
works correct (and gives \r\n per line break).


@Magnus: The editor code is in M-C and they explicitly have this:

>  // Note that we don't need to replace native line breaks with XP line breaks
>  // here because Chrome does not do it.

https://searchfox.org/comm-central/source/mozilla/editor/libeditor/EditorBase.cpp#4985-4986

Instead of changing anything there (which I do not think is a good idea), I would simply sanitize the input for the WebExtension compose.setComposeDetails and replace any \r\n by \n? This is also done in other code paths by the composer directly (https://searchfox.org/comm-central/source/mailnews/compose/src/nsMsgCompose.cpp#2717) but not in this case. Ok with you?
It appears to happen during setting the content already. `SetComposeDetails()` eventually calls `editor.insertText()` . One can also execute the following from the console in a compose window:
```
window.GetCurrentEditor().insertText("123\r\n123\r\n");
```
On Windows 10: The content "looks" right, but if copy-pasted into an editor which is capable of showing line endings, one can see, that the extra \r\n are already there. But it appears the editor collapses \r\n\r\n into a single linebreak. This

```
window.GetCurrentEditor().insertText("123\n123\n");
```
works correct (and gives \r\n per line break).


@Magnus: The editor code is in M-C and they explicitly have this:

>  // Note that we don't need to replace native line breaks with XP line breaks
>  // here because Chrome does not do it.

https://searchfox.org/comm-central/source/mozilla/editor/libeditor/EditorBase.cpp#4985-4986

Instead of changing anything there (which I do not think is a good idea), I would simply sanitize the input for the WebExtension compose.setComposeDetails and replace any \r\n by \n? This is also done in other code paths by the composer directly (https://searchfox.org/comm-central/source/mailnews/compose/src/nsMsgCompose.cpp#2717) but not in this case. Ok with you?

Back to Bug 1672407 Comment 2