Closed Bug 1493978 Opened Last year Closed 11 months ago

Alert dialogs: \r characters are stripped

Categories

(Core :: DOM: Core & HTML, defect, P3)

64 Branch
defect

Tracking

()

RESOLVED FIXED
mozilla64
Tracking Status
firefox64 --- fixed

People

(Reporter: avi, Assigned: ehsan)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3528.4 Safari/537.36

Steps to reproduce:

This is a reporting of an issue within Firefox that was part of an issue discussed on the Chromium bug tracker, crbug.com/887925.

For a call like:
 alert("First line\rSecond line\r\nThird line\nFourth line")

Safari and Edge today treat "\r\n" pairs and lone "\r" values as newlines. Chromium will be adopting this behavior soon.

Firefox apparently takes the shortcut of stripping out "\r" characters. While this works for "\r\n" to turn it into "\n", this means that lone "\r" characters get lost.

Firefox will be alone in this behavior; it should change.
To be clear:

alert("First line\rSecond line\r\nThird line\nFourth line")

should result in a dialog with the text:

First line
Second line
Third line
Fourth line

Currently, Firefox shows a dialog with

First lineSecond line
Third line
Fourth line

which is incorrect; it should allow for a lone \r to terminate a line.
I was able to reproduce this behavior in latest Nightly. 

Build ID 	20180928100051
User Agent 	Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0
Component: Untriaged → DOM: Core & HTML
Product: Firefox → Core
Version: 62 Branch → 64 Branch
https://bugzilla.mozilla.org/show_bug.cgi?id=607640#c2 indicates this was supposedly fixed by bug 263359. Ehsan, do you know about this seeming regression?
Flags: needinfo?(ehsan)
Priority: -- → P3
(In reply to Andrew Overholt [:overholt] from comment #3)
> https://bugzilla.mozilla.org/show_bug.cgi?id=607640#c2 indicates this was
> supposedly fixed by bug 263359. Ehsan, do you know about this seeming
> regression?

That's an unrelated bug, I'm afraid.  That being said, this is super easy to fix, and I have a patch ready.

The spec here doesn't mention anything about the behavior you're describing, Avi <https://html.spec.whatwg.org/#dom-alert>.  Were you planning to file a spec issue to get it changed?  Thanks!
Flags: needinfo?(ehsan) → needinfo?(avi)
https://github.com/whatwg/html/issues/4094 filed, thanks.
Flags: needinfo?(avi)
I wasn't sure how to write a test for this patch, FWIW...
Pushed by eakhgari@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/4868fc98a7b6
Recognize Mac newlines as well as Windows newlines in the string passed to alert/confirm r=qdot
https://hg.mozilla.org/mozilla-central/rev/4868fc98a7b6
Status: NEW → RESOLVED
Closed: 11 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
Assignee: nobody → ehsan
Verified Fixed

Build ID 	20181018123730
User Agent 	Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0
You need to log in before you can comment on or make changes to this bug.