This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 12606 - Form submission should convert all line breaks to CR LF pairs in field names and values
Summary: Form submission should convert all line breaks to CR LF pairs in field names ...
Status: RESOLVED FIXED
Alias: None
Product: HTML WG
Classification: Unclassified
Component: LC1 HTML5 spec (show other bugs)
Version: unspecified
Hardware: PC Windows XP
: P2 normal
Target Milestone: ---
Assignee: Ian 'Hixie' Hickson
QA Contact: HTML WG Bugzilla archive list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-05 12:29 UTC by Hallvord R. M. Steen
Modified: 2011-09-06 07:23 UTC (History)
8 users (show)

See Also:


Attachments
demo with fields set to CR and LF, reports .value and on submit you'll see the encoded result in the URL field (1.07 KB, text/html)
2011-05-05 12:29 UTC, Hallvord R. M. Steen
Details

Description Hallvord R. M. Steen 2011-05-05 12:29:37 UTC
Created attachment 985 [details]
demo with fields set to CR and LF, reports .value and on submit you'll see the encoded result in the URL field

Browsers tend to normalize stray CR and LF characters to CRLF when submitting a form. The algorithm on http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#application/x-www-form-urlencoded-encoding-algorithm doesn't seem to special-case CR and LF at all, I believe this is required.

This applies to both textarea and input type=hidden.
Comment 1 Ian 'Hixie' Hickson 2011-06-21 06:14:51 UTC
Is the test case online anywhere for easy testing?
Comment 2 Hallvord R. M. Steen 2011-06-21 09:08:05 UTC
I've put a copy on http://hallvord.com/temp/W3-12606.htm - you'll still need to look at the address bar to see what was actually sent though.
Comment 3 Michael[tm] Smith 2011-08-04 05:36:04 UTC
mass-move component to LC1
Comment 4 Ian 'Hixie' Hickson 2011-08-10 19:18:57 UTC
For textarea this is already required, search for "The element's value is defined to be the element's raw value with the following transformation applied".

Do we really want to be fiddling with JavaScript-assigned values in <input type=hidden>?
Comment 5 Anne 2011-08-15 10:20:02 UTC
(If this applies to text/plain that format can be reliably decoded in theory.)
Comment 6 Hallvord R. M. Steen 2011-08-15 13:36:44 UTC
(In reply to comment #4)
> Do we really want to be fiddling with JavaScript-assigned values in <input
> type=hidden>?

Since a vast majority of existing UAs do, I believe we should.

(Tested IE, Firefox and Chrome - all normalize JS-assigned values. Only Opera differs, it has not caused us problems that I'm aware of but we intend to change anyway.)

Additionally, Firefox and Chrome normalize form element names with CRs or LFs in them. Haven't checked if this happens during parsing or submit.
Comment 7 Ian 'Hixie' Hickson 2011-08-22 23:08:01 UTC
Please file a separate bugs for the names if you want that looked at. Note that the parser _definitely_ fiddles with CR and LF, so please make sure to create everything in the DOM, not via the parser, when testing this.
Comment 8 Ian 'Hixie' Hickson 2011-08-22 23:55:38 UTC
Actually nevermind. This seems to affect all names and values in a form, and it does seem to happen at submission. Also it doesn't seem limited to the  x-www-form-urlencoded type.

http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1117
Comment 9 Ian 'Hixie' Hickson 2011-09-06 07:23:01 UTC
EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Accepted
Change Description: see diff given below
Rationale: Made it apply all the time.
Comment 10 contributor 2011-09-06 07:23:25 UTC
Checked in as WHATWG revision r6542.
Check-in comment: Match reality: form submission normalises newlines.
http://html5.org/tools/web-apps-tracker?from=6541&to=6542