Closed Bug 324653 Opened 19 years ago Closed 17 years ago

Javascript - bad string length for textareas containing new lines

Categories

(Core :: JavaScript Engine, defect)

1.7 Branch
x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 188015

People

(Reporter: poletto, Unassigned)

Details

Attachments

(1 file)

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?
Duplicate of/related to Core bug 279758 -> Core bug 188015?
(In reply to comment #1)
> Does this occur in Firefox 1.5?
> 

Yes. I found it happened on Firefox 1.5.

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. :-(
Assignee: nobody → general
Component: General → JavaScript Engine
Product: Firefox → Core
QA Contact: general → general
Whiteboard: DUPEME
Version: unspecified → 1.7 Branch
I'll be glad to confirm this when a testcase is provided and attached to the bug.
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).
Oops, you'll have to "save as" the document and test it in local
Great, this is definitely a dupe of bug 188015, then.
Status: UNCONFIRMED → RESOLVED
Closed: 17 years ago
Resolution: --- → DUPLICATE
Whiteboard: DUPEME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: