You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
feat($httpBackend): JSONP requests now require trusted resource
Reject JSONP requests that are not trusted by `$sce` as "ResourceUrl".
This change makes is easier for developers to see clearly where in their
code they are making JSONP calls that may be to untrusted endpoings and
forces them to think about how these URLs are generated.
Be aware that this commit does not put any constraint on the parameters
that will be appended to the URL. Developers should be mindful of what
parameters can be attached and how they are generated.
Closes#11352
BREAKING CHANGE
All JSONP requests now require the URL to be trusted as resource URLs.
There are two approaches to trust a URL:
**Whitelisting with the `$sceDelegateProvider.resourceUrlWhitelist()`
method.**
You configure this list in a module configuration block:
```
appModule.config(['$sceDelegateProvider', function($sceDelegateProvider) {
$sceDelegateProvider.resourceUrlWhiteList([
// Allow same origin resource loads.
'self',
// Allow JSONP calls that match this pattern
'https://some.dataserver.com/**.jsonp?**`
]);
}]);
```
**Explicitly trusting the URL via the `$sce.trustAsResourceUrl(url)`
method**
You can pass a trusted object instead of a string as a URL to the `$http`
service:
```
var promise = $http.jsonp($sce.trustAsResourceUrl(url));
```
0 commit comments