Skip to main content

Bug Tracker

Side navigation

#6876 closed bug (fixed)

Opened August 05, 2010 05:31PM UTC

Closed December 31, 2010 08:03PM UTC

Last modified November 20, 2013 05:08PM UTC

Newline in form data should be encoded as CRLF pair

Reported by: dmethvin Owned by: dmethvin
Priority: low Milestone: 1.5
Component: ajax Version: 1.4.2
Keywords: form,newline,crlf,pair,ajaxrewrite Cc:
Blocked by: Blocking:
Description

See this post:

http://forum.jquery.com/topic/encodeuricomponent-isn-t-sufficient-for-encoding-application-x-www-form-urlencoded#14737000001191209

Summary: The .value property of a textarea returns only LF between lines on all browsers but IE/Opera, but the W3C says lines should be delimited by CRLF when the form is submitted.

http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1

Attachments (0)
Change History (7)

Changed August 06, 2010 12:30AM UTC by dmethvin comment:1

As I read the spec, it seems like *all* line breaks of LF should be replaced with CRLF, which makes the fix easier than special-casing a textarea.

Looks like this could be fixed in serializeArray:

 { name: elem.name, value: val.replace(/\\r?\\n/g, "\\r\\n") };

(In two places...)

Another possibility would be to fix it in .val(), which is currently normalizing line endings by removing the CR in browsers where it's present -- IE and Opera. I like that fix better in some ways but am concerned that it will break too much existing code that expects a lone LF.

Changed October 21, 2010 02:18AM UTC by addyosmani comment:2

keywords: formform newline crlf pair
milestone: 1.4.31.5
priority: → undecided
status: newopen

Marking for review and possible inclusion in 1.5.

Changed December 27, 2010 10:37PM UTC by rwaldron comment:3

keywords: form newline crlf pairform,newline,crlf,pair,ajaxrewrite

Changed December 31, 2010 01:02AM UTC by dmethvin comment:4

owner: → dmethvin
status: openassigned

Changed December 31, 2010 08:03PM UTC by Dave Methvin comment:5

resolution: → fixed
status: assignedclosed

When serializing text, encode all line breaks as CRLF pairs per the application/x-www-form-urlencoded specification. Fixes #6876.

Changeset: eed3803c98bf5c074e40aad12f2e91435bf81154

Changed January 31, 2011 04:26PM UTC by john comment:6

priority: undecidedlow

Changed November 20, 2013 05:08PM UTC by dmethvin comment:7

#14560 is a duplicate of this ticket.