aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2010-12-31 13:56:51 -0600
committerColin Snover <github.com@zetafleet.com>2010-12-31 13:56:51 -0600
commiteed3803c98bf5c074e40aad12f2e91435bf81154 (patch)
tree22830c3ea217d930a675a3b402076cc4650856eb
parent7e2810fa950f24055384e0b3be5b282183540c39 (diff)
downloadjquery-eed3803c98bf5c074e40aad12f2e91435bf81154.tar.gz
jquery-eed3803c98bf5c074e40aad12f2e91435bf81154.zip
When serializing text, encode all line breaks as CRLF pairs per the application/x-www-form-urlencoded specification. Fixes #6876.
-rw-r--r--src/ajax.js4
-rw-r--r--test/unit/ajax.js8
2 files changed, 6 insertions, 6 deletions
diff --git a/src/ajax.js b/src/ajax.js
index 5e58a0fa0..86709005e 100644
--- a/src/ajax.js
+++ b/src/ajax.js
@@ -107,9 +107,9 @@ jQuery.fn.extend({
null :
jQuery.isArray(val) ?
jQuery.map( val, function(val, i){
- return {name: elem.name, value: val};
+ return {name: elem.name, value: val.replace(/\r?\n/g, "\r\n")};
}) :
- {name: elem.name, value: val};
+ {name: elem.name, value: val.replace(/\r?\n/g, "\r\n")};
}).get();
}
});
diff --git a/test/unit/ajax.js b/test/unit/ajax.js
index 4019eb71b..270d32f8b 100644
--- a/test/unit/ajax.js
+++ b/test/unit/ajax.js
@@ -650,20 +650,20 @@ test("serialize()", function() {
'Check input serialization as query string');
equals( jQuery('#testForm').serialize(),
- 'T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=',
+ 'T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=',
'Check form serialization as query string');
equals( jQuery('#testForm :input').serialize(),
- 'T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=',
+ 'T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=',
'Check input serialization as query string');
equals( jQuery('#form, #testForm').serialize(),
- "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3&T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
+ "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3&T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
'Multiple form serialization as query string');
/* Temporarily disabled. Opera 10 has problems with form serialization.
equals( jQuery('#form, #testForm :input').serialize(),
- "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
+ "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
'Mixed form/input serialization as query string');
*/
jQuery("#html5email, #html5number").remove();