From 7fb90a6beaeffe16699800f73746748f6a5cc2de Mon Sep 17 00:00:00 2001 From: Christian Wenz Date: Mon, 6 Apr 2020 21:15:55 +0200 Subject: Ajax: Overwrite s.contentType with content-type header value, if any MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes the issue of "%20" in POST data being replaced with "+" even for requests with content-type different from "application/x-www-form-urlencoded", e.g. for "application/json". Fixes gh-4119 Closes gh-4650 Co-authored-by: Richard Gibson Co-authored-by: Michał Gołębiowski-Owczarek --- src/ajax.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/ajax.js') diff --git a/src/ajax.js b/src/ajax.js index 44ec6e83b..0563c924b 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -861,4 +861,13 @@ jQuery.each( [ "get", "post" ], function( _i, method ) { }; } ); +jQuery.ajaxPrefilter( function( s ) { + var i; + for ( i in s.headers ) { + if ( i.toLowerCase() === "content-type" ) { + s.contentType = s.headers[ i ] || ""; + } + } +} ); + export default jQuery; -- cgit v1.2.3