aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2015-10-22 14:25:32 -0400
committerDave Methvin <dave.methvin@gmail.com>2015-11-02 13:14:46 -0500
commit70605c8e5655da996ebd395e3c43423daaa08d9c (patch)
tree927ac4bad205e9f6689c00440a738cd321f25fea /src
parent015d16c02dae770eda88e644ec69ce82f25c0412 (diff)
downloadjquery-70605c8e5655da996ebd395e3c43423daaa08d9c.tar.gz
jquery-70605c8e5655da996ebd395e3c43423daaa08d9c.zip
Ajax: Only form-encode requests with a body
Fixes #2658 Closes #2671
Diffstat (limited to 'src')
-rw-r--r--src/ajax.js6
-rw-r--r--src/serialize.js4
2 files changed, 8 insertions, 2 deletions
diff --git a/src/ajax.js b/src/ajax.js
index efc413650..289eb2795 100644
--- a/src/ajax.js
+++ b/src/ajax.js
@@ -12,6 +12,7 @@ define( [
], function( jQuery, document, rnotwhite, location, nonce, rquery ) {
var
+ r20 = /%20/g,
rhash = /#.*$/,
rts = /([?&])_=[^&]*/,
rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
@@ -601,6 +602,11 @@ jQuery.extend( {
// Otherwise add one to the end
cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
}
+
+ // Change '%20' to '+' if this is encoded form body content (gh-2658)
+ } else if ( s.data && s.processData &&
+ ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
+ s.data = s.data.replace( r20, "+" );
}
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
diff --git a/src/serialize.js b/src/serialize.js
index 94698fc2f..a0b948460 100644
--- a/src/serialize.js
+++ b/src/serialize.js
@@ -6,7 +6,7 @@ define( [
"./attributes/prop"
], function( jQuery, rcheckableType ) {
-var r20 = /%20/g,
+var
rbracket = /\[\]$/,
rCRLF = /\r?\n/g,
rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
@@ -85,7 +85,7 @@ jQuery.param = function( a, traditional ) {
}
// Return the resulting serialization
- return s.join( "&" ).replace( r20, "+" );
+ return s.join( "&" );
};
jQuery.fn.extend( {