Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Ajax: Drop the json to jsonp auto-promotion logic#4754

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mgol merged 2 commits intojquery:masterfrommgol:no-jsonp-auto-promotion
Jul 27, 2020

Conversation

mgol
Copy link
Member

@mgolmgol commentedJul 18, 2020
edited
Loading

Summary

Previously,jQuery.ajax withdataType: 'json' with a provided callback was
automatically converted to a jsonp request unless one also specified
jsonp: false. Today the preferred way of interacting with a cross-domain
backend is CORS which works in all browsers jQuery 4 will support.

Auto-promoting JSON requests to JSONP ones introduces a security issue as the
developer may be unaware they're not just downloading data but executing code
from a remote domain.

This commit disables the auto-promoting logic.

BREAKING CHANGE: to trigger a JSONP request, it's now required to specify
dataType: "jsonp"; previously some requests withdataType: "json" were
auto-promoted to JSONP.

Fixesgh-1799
Fixesgh-3376

Checklist

@Krinkle
Copy link
Member

Is this something the migrate plugin could feasilby detect, fix, and warn about without false positives?

@dmethvin
Copy link
Member

@Krinkle I think it should be possible to detect and warn about this.

Previously, `jQuery.ajax` with `dataType: 'json'` with a provided callback wasautomatically converted to a jsonp request unless one also specified`jsonp: false`. Today the preferred way of interacting with a cross-domainbackend is CORS which works in all browsers jQuery 4 will support.Auto-promoting JSON requests to JSONP ones introduces a security issue as thedeveloper may be unaware they're not just downloading data but executing codefrom a remote domain.This commit disables the auto-promoting logic.BREAKING CHANGE: to trigger a JSONP request, it's now required to specify`dataType: "jsonp"`; previously some requests with `dataType: "json"` wereauto-promoted to JSONP.Fixesjquerygh-1799Fixesjquerygh-3376
@mgol
Copy link
MemberAuthor

I added tests for issue#1799 since the logic will now be skipped for regular JSON requests.

@mgolmgol added the Discuss in MeetingReserved for Issues and PRs that anyone would like to discuss in the weekly meeting. labelJul 22, 2020
@mgol
Copy link
MemberAuthor

I've also just submitted a Migrate PR:jquery/jquery-migrate#376.

@timmywiltimmywil removed the Discuss in MeetingReserved for Issues and PRs that anyone would like to discuss in the weekly meeting. labelJul 27, 2020
@mgolmgol merged commite7b3bc4 intojquery:masterJul 27, 2020
@mgolmgol deleted the no-jsonp-auto-promotion branchJuly 27, 2020 17:16
mgol added a commit to mgol/jquery that referenced this pull requestJul 29, 2020
This aligns the Node.js server with the previous PHP one in accepting `mock.php`as a callback which is triggered by a recently added test. This prevents therequest crashing on that Node.js server and printing a JS error:```TypeError: Cannot read property '1' of null```Refjquerygh-4754
mgol added a commit to jquery/jquery-migrate that referenced this pull requestAug 31, 2020
mgol added a commit to mgol/jquery that referenced this pull requestSep 2, 2020
This aligns the Node.js server with the previous PHP one in accepting `mock.php`as a callback which is triggered by a recently added test. This prevents therequest crashing on that Node.js server and printing a JS error:```TypeError: Cannot read property '1' of null```Refjquerygh-4754
mgol added a commit that referenced this pull requestSep 2, 2020
This aligns the Node.js server with the previous PHP one in sending `mock.php`as a callback if there's no `callback` parameter in the query string which istriggered by a recently added test. This prevents the request crashing on thatNode.js server and printing a JS error:```TypeError: Cannot read property '1' of null```Closesgh-4764Refgh-4754
mgol added a commit to mgol/jquery that referenced this pull requestSep 2, 2020
This aligns the Node.js server with the previous PHP one in sending `mock.php`as a callback if there's no `callback` parameter in the query string which istriggered by a recently added test. This prevents the request crashing on thatNode.js server and printing a JS error:```TypeError: Cannot read property '1' of null```Closesjquerygh-4764Refjquerygh-4754(cherry picked from commitdf6858d)
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@dmethvindmethvindmethvin approved these changes

@timmywiltimmywiltimmywil approved these changes

@gibson042gibson042gibson042 approved these changes

Assignees

@mgolmgol

Milestone
4.0.0
Development

Successfully merging this pull request may close these issues.

Drop the json-to-jsonp auto-promoting logic Question mark is replaced by 'jQuery1520046861610282212496_1411972375451'.
5 participants
@mgol@Krinkle@dmethvin@timmywil@gibson042

[8]ページ先頭

©2009-2025 Movatter.jp