New issue
Advanced search Search tips

Issue 887925 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Sep 25
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Mac
Pri: 2
Type: Bug



Sign in to add a comment

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".
 
chrome.PNG
4.2 KB View Download
edge.PNG
3.1 KB View Download
firefox.PNG
2.9 KB View Download
internetexplorer.PNG
2.8 KB View Download
alert.htm
166 bytes View Download
Labels: Needs-Triage-M69
Components: Blink>HTML
Labels: Triaged-ET Target-71 M-71 FoundIn-71 OS-Linux OS-Mac
Status: Untriaged (was: Unconfirmed)
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...!!
Cc: a...@chromium.org
Components: -Blink>HTML Blink>WindowDialog
Owner: a...@chromium.org
Status: Assigned (was: Untriaged)
It seems like Firefox just strips \rs.
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.
Screen Shot 2018-09-25 at 12.08.03 AM.png
38.2 KB View Download
Screen Shot 2018-09-25 at 12.08.28 AM.png
27.4 KB View Download
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".
Edge.png
3.4 KB View Download
Firefox.png
1.9 KB View Download
chrome.png
5.1 KB View Download
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.
Project Member

Comment 10 by bugdroid1@chromium.org, 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

Status: Fixed (was: Assigned)

Sign in to add a comment