encodeURIComponent isn't sufficient for encoding application/x-www-form-urlencoded
Heya,
I'm struggling with form serialization in jQuery 1.4.2, in a Rails 2.3.8 project.
I'm ajax-posting a form containing a textarea, grabbing the form contents using $(form).serializeArray().
$.ajax uses $.param to serialize the contents, which in turn uses encodeURIComponent. If my textarea contains:
foo
"bar"
baz
then the resulting request body contains
text=foo "bar" baz
which Rack/Rails manages to deserialize as simply "text"=>"bar". *
Line breaks are represented as "CR LF" pair
s (i.e., ` ').
Shouldn't jquery be normalizing the output of encodeURIComponent to convert plain linefeeds to CRLFs?
-Jonathan
*: Oddly, if the 2nd line doesn't have quotes around it, the params parser is able to get the entire contents of the 'text' value.