under windows javascript function substring() is interrupting a new line "\r\n" as "1" character when it should be "2" characters

RESOLVED INVALID

Status

()

Core
DOM
RESOLVED INVALID
6 years ago
3 years ago

People

(Reporter: John, Unassigned)

Tracking

({regression})

2.0 Branch
x86
Windows Server 2003
regression
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(4 attachments, 1 obsolete attachment)

2.16 KB, text/html
Details
88.92 KB, image/jpeg
Details
84.51 KB, image/jpeg
Details
341 bytes, text/html
Details
(Reporter)

Description

6 years ago
Created attachment 667367 [details]
test.html

User Agent: Mozilla/5.0 (Windows NT 5.2; rv:12.0) Gecko/20100101 Firefox/12.0
Build ID: 20120420145725

Steps to reproduce:

made a little highlight a word script to show you the problem... script works fine in all browsers but Firefox. As a side note...this test script works in Firefox up to version 8.0, but not after that.


Actual results:

wrong result... (spell ~ iframe result)

<html>
	<head>
		<style>
			body { background-color : #ffffff; font-family : arial, helvetica, sans-serif; margin : 0px; padding : 4px }
			.nsw, .swe { font-size : 12px }
			.nsw { color : #252525 }
			.tab { padding-left : 3em }
			.swe { color : #fa6105; border : 1px solid #91d591; padding-left : 2px; padding-right : 2px; background : #e7f4e7 }
		</style>
	</head>
	<body>
		<div class='nsw'>hippos<br /><br /><br /><br /><br />peopl<span id='highlight' class='swe'>peoplez</span>eep<br /><br />newz<br /></div>
	</body>
</html>



Expected results:

correct result... (spell ~ iframe result)

<html>
	<head>
		<style>
			body { background-color : #ffffff; font-family : arial, helvetica, sans-serif; margin : 0px; padding : 4px }
			.nsw, .swe { font-size : 12px }
			.nsw { color : #252525 }
			.tab { padding-left : 3em }
			.swe { color : #fa6105; border : 1px solid #91d591; padding-left : 2px; padding-right : 2px; background : #e7f4e7 }
		</style>
	</head>
	<body>
		<div class='nsw'>hippos<br /><br /><br /><br /><br /><span id='highlight' class='swe'>peoplez</span><br /><br /><br />keeep<br /><br />newz<br /></div>
	</body>
</html>
(Reporter)

Comment 1

6 years ago
Created attachment 667371 [details]
test.html

sorry...

fixed test example to remove extra document.write code
Attachment #667367 - Attachment is obsolete: true

Updated

6 years ago
Attachment #667371 - Attachment mime type: text/plain → text/html

Comment 2

6 years ago
I see the same result with FF8 and FF15. Could you attach a screenshot please.
(Reporter)

Comment 3

6 years ago
I have attached a firefox 12 screen shot, and a firefox 3 screen shot. I don't know exactly when the javascript engine changed the way it handles new lines on a windows machine, but it was changed because this script once supported all browsers but now it seems I have to add browser identification hacks because some newer browsers, newer versions of those browsers, are using the newer javascript engine which is interrupting \r\n as a single character and that is wrong.
(Reporter)

Comment 4

6 years ago
Created attachment 667725 [details]
firefox 12
(Reporter)

Comment 5

6 years ago
Created attachment 667726 [details]
firefox 3
(Reporter)

Comment 6

6 years ago
Okay... after doing a lot of testing, the changed happened in firefox 6.0.2, in firefox 6.0.1 the code works fine, but it stops working in firefox 6.0.2

Comment 7

6 years ago
There is a regression since Firefox 3.7a5pre:

m-c
2010-05-03
2010-05-04
http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=83c887dff0da&tochange=d6bb0f9e9519

I'd say the suspected bug is:
Olli Pettay — Bug 562013 - parse innerHTML directly to the destination node, p=smaug+hsivonen, r=sicking
Status: UNCONFIRMED → NEW
Component: Untriaged → DOM
Ever confirmed: true
Keywords: regression, regressionwindow-wanted
Product: Firefox → Core
Version: 12 Branch → 2.0 Branch
A *minimal* testcase would be great.

Bug 562013  has nothing to do with substring(), I wonder what this bug is about.

Comment 9

6 years ago
Created attachment 667765 [details]
test


The difference is length of "\r\n" in hidden input tag, not substring().

In Firefox3.6  : length of "\r\n" in hidden input tag is treated 2
In Firefox4.0+ : length of "\r\n" in hidden input tag is treated 1

Comment 10

6 years ago
"\r\n" in hidden input tag is treated 2:
http://hg.mozilla.org/mozilla-central/rev/83c887dff0da
Mozilla/5.0 (Windows; U; Windows NT 6.1; WOW64; en-US; rv:1.9.3a5pre) Gecko/20100503 Minefield/3.7a5pre ID:20100503040502
"\r\n" in hidden input tag is treated 1:
http://hg.mozilla.org/mozilla-central/rev/3a7920df7580
Mozilla/5.0 (Windows; U; Windows NT 6.1; WOW64; en-US; rv:1.9.3a5pre) Gecko/20100503 Minefield/3.7a5pre ID:20100503105056
Pushlog:
http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=83c887dff0da&tochange=3a7920df7580
Triggered by:
358113b3642e	Henri Sivonen — Bug 373864 - Enable the HTML5 parser by default. r+sr=jst.

And also, the behavior of Firefox4+ is as same as Google Chrome22.0.1229.79 m and Opera12.02.
http://dev.w3.org/html5/spec/single-page.html#concept-textarea-api-value
> The element's API value is defined to be the element's raw value with the following transformation applied:
> 1. Replace every U+000D CARRIAGE RETURN U+000A LINE FEED (CRLF) character pair from the raw value with a single "LF" (U+000A) character.
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → INVALID
Keywords: regressionwindow-wanted
You need to log in before you can comment on or make changes to this bug.