Closed Bug 263136 Opened 21 years ago Closed 21 years ago

Newline characters pasted into text field are taken into account

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
minor

Tracking

()

VERIFIED DUPLICATE of bug 77932

People

(Reporter: frederic.jecker, Assigned: bugzilla)

Details

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20040913 Firefox/0.10 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20040913 Firefox/0.10 When text with a leading newline character is copied in the Clipboard it is possible to paste it in a form text field. The newline character is present in the field (but not visible) When submiting the form, the character is sent and can create some errors (ie when accessing the field content whith script) Reproducible: Always Steps to Reproduce: 1.Create a simple form with an <input type="text"> field 2.Create a server side script (php... whatever) that receives the content of the form once submitted 3.Open a Notepad, press <enter> and then type some text 4.Select all the lines, and copy them to the clipboard 5.Paste the content of the clipboard in the field and then submit it Actual Results: When parsing the content of the form's data, the first character of the data contained in the field is the new line character. The newline character isn't visible from the user. Expected Results: When you are in a simple text field, and that you type enter, the newline isn't take into accout. As well as if you try to paste multi line text in such a field, only the first line is taken into accout. Firefox should trim the pasted string and remove leading and trailing newline characters.
So, depending on where you want to paste it, <textarea> or <input>, FF should not remove newline characters ( <textarea> ) or remove them ( <input> ) ? Doesn't sound very logic for a paste command. WONT ?
By default, input tags are designed to contain single line text on the contrary to textareas which can contain more than one line. It sounds logical for me that newlines characters have nothing to do in inputs ! ie: select and copy four line of text in the clipboard and paste it into an input tag: FF draws all the lines except the first one which is placed into the input. So why if the first line is empty FF doen't do the same thing (or only paste the next line) other example: in an input, juste type text, and then a couple of times the return key : what happens ? the newline is ignored and you can continue to add some text in it whithout having your text splitted on more than one line !!
AFAICS the input element's[1] value attribute is of type CDATA without any further restrictions. There is no need to exclude any whitespace characters on client side. But you may exclude them by rules and refuse them serverside. [1]http://www.w3.org/TR/html4/interact/forms.html#edef-INPUT
The problem is not on excluding whitespaces in input elements but newline characters Try yourself: when you press return in an input field no newline character is placed in the field, so why should it be done when you paste a newline into it !
It's a valid request, but severity is minimal, since an easy workaround exists (i.e. stripping newlines in your server-side script). Is there code in gecko that suppresses the display of newlines in input elements?
Severity: normal → minor
*** This bug has been marked as a duplicate of 77932 ***
Status: UNCONFIRMED → RESOLVED
Closed: 21 years ago
Resolution: --- → DUPLICATE
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.