- Notifications
You must be signed in to change notification settings - Fork20.6k
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Is this something the migrate plugin could feasilby detect, fix, and warn about without false positives? |
@Krinkle I think it should be possible to detect and warn about this. |
b29bbd0
tob1bece3
ComparePreviously, `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
I added tests for issue#1799 since the logic will now be skipped for regular JSON requests. |
I've also just submitted a Migrate PR:jquery/jquery-migrate#376. |
Uh oh!
There was an error while loading.Please reload this page.
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
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
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
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)
Uh oh!
There was an error while loading.Please reload this page.
Summary
Previously,
jQuery.ajax
withdataType: '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 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"
wereauto-promoted to JSONP.
Fixesgh-1799
Fixesgh-3376
Checklist