Skip to content

Ajax: Execute JSONP error script responses #4773

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

Merged
merged 10 commits into from
Aug 25, 2020
Merged

Conversation

fras2560
Copy link
Contributor

@fras2560 fras2560 commented Aug 20, 2020

Fixes: #4771
However, it should not parse the response if just a script

However, it should not parse the response if just a script
@jsf-clabot
Copy link

jsf-clabot commented Aug 20, 2020

CLA assistant check
All committers have signed the CLA.

@timmywil
Copy link
Member

Thanks for opening a PR. Is there an issue already open to go with this?

@fras2560
Copy link
Contributor Author

@timmywil yes PR #4771

@timmywil
Copy link
Member

Thanks

Copy link
Member

@mgol mgol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! This is a very good start. I added some comments.

@mgol
Copy link
Member

mgol commented Aug 21, 2020

Please sign our CLA, we can't merge the PR without that.

@timmywil timmywil changed the title #4771 The fix works for me such that parses the jsonp response #4771 Parse JSONP-only script responses Aug 21, 2020
Copy link
Member

@mgol mgol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@mgol mgol added this to the 3.6.0 milestone Aug 22, 2020
@fras2560
Copy link
Contributor Author

@mgol Thanks for the approving it. Any idea on how long it will take before the next release of jQuery? I am just wondering whether will need to patch in before the company next release cycle.

@mgol
Copy link
Member

mgol commented Aug 22, 2020

@fras2560 we don’t have a fixed release schedule & a lot depends on how fast we fix other issues in the 3.6.0 milestone. But unless we get PRs for most of those issues, I’d assume it may take a few months.

@mgol mgol removed the Needs review label Aug 24, 2020
@mgol mgol modified the milestones: 3.6.0, 4.0.0 Aug 25, 2020
@mgol mgol added this to the 3.6.0 milestone Aug 25, 2020
@mgol mgol changed the title #4771 Parse JSONP-only script responses Ajax: Execute JSONP error script responses Aug 25, 2020
@mgol mgol merged commit a1e619b into jquery:master Aug 25, 2020
mgol pushed a commit that referenced this pull request Aug 25, 2020
Issue gh-4379 was meant to be a bug fix but the JSONP case is a bit special:
under the hood it's a script but it simulates JSON responses in an environment
without a CORS setup and sending JSON payloads on error responses is quite
typical there.

This commit makes JSONP error responses still execute the payload. The regular
script error responses continue to be skipped.

Fixes gh-4771
Closes gh-4773

(cherry picked from commit a1e619b)
@mgol
Copy link
Member

mgol commented Aug 25, 2020

Landed on master in a1e619b and on 3.x-stable in 3bae54a.

@mgol
Copy link
Member

mgol commented Aug 25, 2020

The new test failed on master, probably due to #4754. Investigating...

@mgol
Copy link
Member

mgol commented Aug 26, 2020

Actually, it's because of #4763. The current solution passes the tests on 3.x but it wouldn't pass a cross domain one and #4763 made more requests like cross domain.

I'm working on a fix, it will need to be applied to both branches.

@mgol
Copy link
Member

mgol commented Aug 26, 2020

From what I see, JSONP error responses have never been passed to the error callback for cross domain requests. So we can probably leave it as-is on 3.x-stable, this would be a feature request and with JSONP being a legacy communication method perhaps it's fine this way.

mgol added a commit to mgol/jquery that referenced this pull request Aug 26, 2020
Don't use a script tag for JSONP requests unless for cross-domain requests
or if scriptAttrs are provided. This makes the `responseJSON` property available
in JSONP error callbacks.

This fixes a regression from jQuery 3.5.0 introduced in jquerygh-4379 which made
erroneous script responses to not be executed to follow native behavior.

The 3.x-stable branch doesn't need this fix as it doesn't use script tags for
regular async requests.

Ref jquerygh-4771
Ref jquerygh-4773
Ref jquerygh-4379
@mgol
Copy link
Member

mgol commented Aug 26, 2020

Fix for master available at #4778. The 3.x-stable branch is fine as-is.

mgol added a commit that referenced this pull request Aug 31, 2020
Don't use a script tag for JSONP requests unless for cross-domain requests
or if scriptAttrs are provided. This makes the `responseJSON` property available
in JSONP error callbacks.

This fixes a regression from jQuery 3.5.0 introduced in gh-4379 which made
erroneous script responses to not be executed to follow native behavior.

The 3.x-stable branch doesn't need this fix as it doesn't use script tags for
regular async requests.

Closes gh-4778
Ref gh-4771
Ref gh-4773
Ref gh-4379
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

JSONP and parsing responseText upon 409 Conflict
4 participants