Closed Bug 65857 Opened 24 years ago Closed 24 years ago

trailing whitespaces confuse form field value

Categories

(Core :: DOM: Editor, defect, P3)

defect

Tracking

()

VERIFIED FIXED
mozilla0.8

People

(Reporter: wo, Assigned: kinmoz)

Details

(Keywords: testcase)

Attachments

(2 files)

When you have a text field whose value ends with two whitespaces, assigning that same value with one of the whitespaces removed has no effect. That is, after the assignment, the value still ends with two whitespaces. This only happens with exactly *two* whitespaces. Here is a testcase: (in the alert box the whitespaces are displayed as exclamation marks) <form> <input type="text" value="thisisfollowedbytwospaces " size="50"> <input type="button" onclick="trim()" value="shorten"> </form> <script> function trim() { w=document.forms[0].elements[0].value; w2=w.substring(0, w.length-1); document.forms[0].elements[0].value=w2; w3=document.forms[0].elements[0].value; alert(w2.replace(/ /g, '!')+" was assigned to form field.\n" +"form field value now: "+w3.replace(/ /g, '!')); } </script> this can be dangerous because it can cause infinite loops when you recursively chop the last character of the field - as soon as two whitespaces are reached, the recursion will never halt.
Attached file the testcase (deleted) —
Confirmed Platform: PC OS: Windows 98 Mozilla Build: 2001011704 Marking NEW.
Severity: normal → major
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: testcase
OS: Windows 98 → All
Hardware: PC → All
Looks like this is an editor problem, the correct strings are passed into the editor in the form control but when the value is requested from the edito in the form control again it's not the value that was passed to it earlier (i.e. the last whitespace was not chopped off). Reassigning.
Assignee: jst → beppe
Component: DOM Level 0 → Editor
QA Contact: desale → sujay
assigning to kin for initial eval, also adding jfrancis and akkana
Assignee: beppe → kin
Severity: major → normal
Priority: -- → P3
I guess this is truly the bug from outer space.
I did a quick look in the debugger and it looks like the mPreformatted flag in the encoder is not being set so we fall into the code that thinks it is writing out HTML since the start and end parent in the range being processed is a DIV.
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla0.8
Attached patch Patch that fixes the bug. (deleted) — Splinter Review
I just attatched a patch that fixes this bug. Can I get an r= from either akkana or jfrancis and a super review from sfraser?
Whiteboard: FIX IN HAND
Yes, that makes much more sense than what it was doing before. r=akkana.
sr=sfraser
Fix checked into TRUNK: mozilla/layout/html/forms/src/nsGfxTextControlFrame2.cpp revision 1.121
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Whiteboard: FIX IN HAND
marking verified...
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: