Bug Tracker

Ticket #6876 (closed bug: fixed)

Opened 4 years ago

Last modified 12 months ago

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:
Blocking: Blocked by:

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

Change History

comment:1 Changed 4 years ago by dmethvin

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.

comment:2 Changed 4 years ago by addyosmani

  • Keywords newline crlf pair added
  • Priority set to undecided
  • Status changed from new to open
  • Milestone changed from 1.4.3 to 1.5

Marking for review and possible inclusion in 1.5.

comment:3 Changed 4 years ago by rwaldron

  • Keywords form,newline,crlf,pair,ajaxrewrite added; form newline crlf pair removed

comment:4 Changed 4 years ago by dmethvin

  • Owner set to dmethvin
  • Status changed from open to assigned

comment:5 Changed 4 years ago by Dave Methvin

  • Status changed from assigned to closed
  • Resolution set to fixed

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

Changeset: eed3803c98bf5c074e40aad12f2e91435bf81154

comment:6 Changed 4 years ago by john

  • Priority changed from undecided to low

comment:7 Changed 12 months ago by dmethvin

#14560 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.