-
Notifications
You must be signed in to change notification settings - Fork 20.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid encoding of %20 char sequence in $.ajax post, put body #4119
Comments
I agree with your analysis! If we're letting the header override the setting I guess we should honor both. Would you like to file a pull request? |
Yes, but it may take a time to read all community guides. However hope a fix for this is not urgent ) |
Hi, is there any update on this? |
@Gomathy97 The summary is in #4123 (comment) & #4123 (comment). We welcome PRs, that's the easiest way to make the fix be available sooner. |
Overwrite s.contentType with content-type header value, if any Fixes jquery#4119
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 <richard.gibson@gmail.com> Co-authored-by: Michał Gołębiowski-Owczarek <m.goleb@gmail.com>
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 (cherry picked from 7fb90a6) Co-authored-by: Richard Gibson <richard.gibson@gmail.com> Co-authored-by: Michał Gołębiowski-Owczarek <m.goleb@gmail.com>
Description
Seems that jQuery 3 replaces
%20
char sequence to+
in a request body during PUT and POST. A request likeactually sends
{"val":"+"}
in 3.2.1 and 3.3.1, both with Migration tools.jQuery however 2.x behaves correctly.
Update. Seems the reason is this block https://github.com/jquery/jquery/blob/master/src/ajax.js#L617-L621. It assumes
s.contentType
is the only source ofContent-Type
header, but there can bes.headers['content-type']
, which later (https://github.com/jquery/jquery/blob/master/src/ajax.js#L648-L650) overridess.contentType
value.The text was updated successfully, but these errors were encountered: