Javascript - bad string length for textareas containing new lines

RESOLVED DUPLICATE of bug 188015

Status

()

Core
JavaScript Engine
RESOLVED DUPLICATE of bug 188015
12 years ago
4 years ago

People

(Reporter: poletto, Unassigned)

Tracking

1.7 Branch
x86
Windows XP
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

12 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; fr-FR; rv:1.7.12) Gecko/20050919 Firefox/1.0.7
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr-FR; rv:1.7.12) Gecko/20050919 Firefox/1.0.7

Firefox' javascript engine takes line feeds for 1 character ('\n' i think) when fetching the length property of the string value of a textarea, even on windows.
The thing is that when submitting the form, the textarea value has '\r\n' line feeds and thus, the length is not the same.

Reproducible: Didn't try

Steps to Reproduce:
1. Make a tiny html document with a form and a textarea. Under "onkeyup" event, show the length of the string in textarea (ex : "alert(this.value.length);").
2. Type some text (with some newlines), yes you will be annoyed by the alert window
3. Make a receiver script (in php for example) and print the value of the textarea (using var_dump() for example)

Actual Results:  
The length of the textarea field value in the receiver script is not the same than the length in javascript


* Have not tried in PHP but in CGI/C.
* I use Firefox 1.0.7
* IE counts 2 chars for a line break
Does this occur in Firefox 1.5?

Comment 2

12 years ago
Duplicate of/related to Core bug 279758 -> Core bug 188015?

Comment 3

12 years ago
(In reply to comment #1)
> Does this occur in Firefox 1.5?
> 

Yes. I found it happened on Firefox 1.5.

Comment 4

12 years ago
This is reproducible: always.

Can the status please be set to NEW or preferably ASSIGNED. This particular bug is causing probs here at UTas. It is very annoying to have apps function correctly in IE but not in Moz based browsers. :-(

Updated

11 years ago
Assignee: nobody → general
Component: General → JavaScript Engine
Product: Firefox → Core
QA Contact: general → general
Whiteboard: DUPEME
Version: unspecified → 1.7 Branch

Comment 5

11 years ago
I'll be glad to confirm this when a testcase is provided and attached to the bug.
(Reporter)

Comment 6

11 years ago
Created attachment 267160 [details]
js linefeed string length bug testcae

When you enter some text, the character counter is updated. When you enter some line feeds, they are counted as 1 character.
Now, submit the form, you'll get the submitted value length (which differs because line breaks are CRLF = 2 chars).
(Reporter)

Comment 7

11 years ago
Oops, you'll have to "save as" the document and test it in local

Comment 8

11 years ago
Great, this is definitely a dupe of bug 188015, then.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 11 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 188015

Updated

4 years ago
Whiteboard: DUPEME
You need to log in before you can comment on or make changes to this bug.