Chrome interprets the "\r\n" sequence as 2 line breaks in alert and confirm boxes
Reported by
guillaum...@hotmail.com,
Sep 21
|
|||||
Issue description
UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
Steps to reproduce the problem:
Display a string that contains line-breaks expressed using the Windows format "Carriage Return + Line Feed" ("\r\n") using an alert box (or a confirm box).
eg: alert("First line\r\nSecond line\r\nThird line");
What is the expected behavior?
An alert box to be display, with one line break per pairs of "\r\n".
What went wrong?
Chrome displays two line breaks: one for "\r" and one for "\n".
See attached screenshots taken on various browsers.
Did this work before? N/A
Does this work in other browsers? Yes
Chrome version: 69.0.3497.100 Channel: stable
OS Version: 10.0
Flash Version:
The fact that Chrome is not inline with the other browsers on the market makes it difficult to display alert or confirm boxes in a cross-browser way.
Also, when working on a Windows environment, the default line break is "\r\n", making it harder to work with single "\n".
,
Sep 24
Able to reproduce the issue on Mac 10.13.3, Win-10 and Ubuntu 14.04 using chrome reported version #69.0.3497.100 and latest canary #71.0.3558.0. This is a non-regression issue as it is observed from M60 old builds. Hence, marking it as untriaged to get more inputs from dev team. Thanks...!!
,
Sep 25
,
Sep 25
,
Sep 25
It seems like Firefox just strips \rs.
,
Sep 25
While Safari treats "\r\n" == sole "\r" == sole "\n".
If you do alert("First line\rSecond line\r\nThird line\nFourth line") I don't think you'll see agreement. Safari and Firefox don't agree. What does Edge do? I don't care what IE does. It's not a relevant browser any more.
,
Sep 25
Here are the results for alert("First line\rSecond line\r\nThird line\nFourth line") on various browsers on Windows.
I'm not sure that treating the sequence "\r\n" as two individual characters is a good idea...
Talking about relevance, the "\r" used on its own does not make much sense nowadays. Line breaks are commonly expressed using either "\n" or "\r\n".
,
Sep 25
I agree that \r doesn't make sense alone today, but given that both Edge and Safari treat it as a full-fledged linebreak, I'm going to make Chrome match and point out to Firefox that they disagree.
,
Sep 25
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/4891b851ad47d76b8504e8ca977d72f09543662a commit 4891b851ad47d76b8504e8ca977d72f09543662a Author: Avi Drissman <avi@chromium.org> Date: Tue Sep 25 18:12:58 2018 Normalize newline characters in JS dialogs. BUG= 887925 TEST=WebContentsImplBrowserTest.JavaScriptDialogsNormalizeText Change-Id: Ibea163e5cc8822c427d2278717b5d1c8316d6be4 Reviewed-on: https://chromium-review.googlesource.com/1243226 Reviewed-by: Leonard Grey <lgrey@chromium.org> Commit-Queue: Avi Drissman <avi@chromium.org> Cr-Commit-Position: refs/heads/master@{#594008} [modify] https://crrev.com/4891b851ad47d76b8504e8ca977d72f09543662a/content/browser/web_contents/web_contents_impl.cc [modify] https://crrev.com/4891b851ad47d76b8504e8ca977d72f09543662a/content/browser/web_contents/web_contents_impl.h [modify] https://crrev.com/4891b851ad47d76b8504e8ca977d72f09543662a/content/browser/web_contents/web_contents_impl_browsertest.cc
,
Sep 25
|
|||||
►
Sign in to add a comment |
|||||
Comment 1 by vamshi.kommuri@chromium.org
, Sep 23