Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit a206e26

Browse files
josephperrottpetebacondarwin
authored andcommitted
refactor(sceDelegateProvider): remove usages of whitelist and blacklist
Changes resourceUrlWhitelist to trustedResourceUrlList and resourceUrlBlacklist to bannedResourceUrlList, updating references to use this new symbol. For the purposes of backward compatibility, the previous symbols are aliased to their new symbol.
1 parent 9679e58 commit a206e26

File tree

12 files changed

+144
-122
lines changed

12 files changed

+144
-122
lines changed

Diff for: docs/content/error/$sce/imatcher.ngdoc

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
@fullName Invalid matcher (only string patterns and RegExp instances are supported)
44
@description
55

6-
Please see {@link $sceDelegateProvider#resourceUrlWhitelist
7-
$sceDelegateProvider.resourceUrlWhitelist} and {@link
8-
$sceDelegateProvider#resourceUrlBlacklist $sceDelegateProvider.resourceUrlBlacklist} for the
6+
Please see {@link $sceDelegateProvider#trustedResourceUrlList
7+
$sceDelegateProvider.trustedResourceUrlList} and {@link
8+
$sceDelegateProvider#bannedResourceUrlList $sceDelegateProvider.bannedResourceUrlList} for the
99
list of acceptable items.

Diff for: docs/content/error/$sce/insecurl.ngdoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ By default, only URLs that belong to the same origin are trusted. These are urls
1515
The {@link ng.directive:ngInclude ngInclude} directive and {@link guide/directive directives} that specify a `templateUrl` require a trusted resource URL.
1616

1717
To load templates from other domains and/or protocols, either adjust the {@link
18-
ng.$sceDelegateProvider#resourceUrlWhitelist whitelist}/ {@link
19-
ng.$sceDelegateProvider#resourceUrlBlacklist blacklist} or wrap the URL with a call to {@link
18+
ng.$sceDelegateProvider#trustedResourceUrlList trusted resource URL list}/ {@link
19+
ng.$sceDelegateProvider#bannedResourceUrlList banned resource URL list} or wrap the URL with a call to {@link
2020
ng.$sce#trustAsResourceUrl $sce.trustAsResourceUrl}.
2121

2222
**Note**: The browser's [Same Origin

Diff for: docs/content/error/$sce/iwcard.ngdoc

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
@fullName The sequence *** is not a valid pattern wildcard
44
@description
55

6-
The strings in {@link $sceDelegateProvider#resourceUrlWhitelist
7-
$sceDelegateProvider.resourceUrlWhitelist} and {@link
8-
$sceDelegateProvider#resourceUrlBlacklist $sceDelegateProvider.resourceUrlBlacklist} may not
6+
The strings in {@link $sceDelegateProvider#trustedResourceUrlList
7+
$sceDelegateProvider.trustedResourceUrlList} and {@link
8+
$sceDelegateProvider#bannedResourceUrlList $sceDelegateProvider.bannedResourceUrlList} may not
99
contain the undefined sequence `***`. Only `*` and `**` wildcard patterns are defined.

Diff for: docs/content/guide/migration.ngdoc

+4-4
Original file line numberDiff line numberDiff line change
@@ -1387,12 +1387,12 @@ $http.json('other/trusted/url', {jsonpCallbackParam: 'cb'});
13871387
all JSONP requests now require the URL to be trusted as a resource URL. There are two approaches to
13881388
trust a URL:
13891389

1390-
1. **Whitelisting with the `$sceDelegateProvider.resourceUrlWhitelist()` method.**
1390+
1. **Setting trusted resource URLs with the `$sceDelegateProvider.trustedResourceUrlList()` method.**
13911391
You configure this list in a module configuration block:
13921392

13931393
```js
13941394
appModule.config(['$sceDelegateProvider', function($sceDelegateProvider) {
1395-
$sceDelegateProvider.resourceUrlWhitelist([
1395+
$sceDelegateProvider.trustedResourceUrlList([
13961396
// Allow same origin resource loads.
13971397
'self',
13981398
// Allow JSONP calls that match this pattern
@@ -2662,11 +2662,11 @@ $scope.findTemplate = function(templateName) {
26622662
return templateCache[templateName];
26632663
};
26642664

2665-
// Alternatively, use `$sceDelegateProvider.resourceUrlWhitelist()`, which means you don't
2665+
// Alternatively, use `$sceDelegateProvider.trustedResourceUrlList()`, which means you don't
26662666
// have to use `$sce.trustAsResourceUrl()` at all:
26672667

26682668
angular.module('myApp', []).config(function($sceDelegateProvider) {
2669-
$sceDelegateProvider.resourceUrlWhitelist(['self', 'https://example.com/templates/**'])
2669+
$sceDelegateProvider.trustedResourceUrlList(['self', 'https://example.com/templates/**'])
26702670
});
26712671
```
26722672

Diff for: src/Angular.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1532,7 +1532,7 @@ function allowAutoBootstrap(document) {
15321532
link.href = src.value;
15331533

15341534
if (document.location.origin === link.origin) {
1535-
// Same-origin resources are always allowed, even for non-whitelisted schemes.
1535+
// Same-origin resources are always allowed, even for banned URL schemes.
15361536
return true;
15371537
}
15381538
// Disabled bootstrapping unless angular.js was loaded from a known scheme used on the web.

Diff for: src/ng/compile.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1106,8 +1106,8 @@
11061106
*
11071107
* Based on the context, other options may exist to mark a value as trusted / configure the behavior
11081108
* of {@link ng.$sce}. For example, to restrict the `RESOURCE_URL` context to specific origins, use
1109-
* the {@link $sceDelegateProvider#resourceUrlWhitelist resourceUrlWhitelist()}
1110-
* and {@link $sceDelegateProvider#resourceUrlBlacklist resourceUrlBlacklist()}.
1109+
* the {@link $sceDelegateProvider#trustedResourceUrlList trustedResourceUrlList()}
1110+
* and {@link $sceDelegateProvider#bannedResourceUrlList bannedResourceUrlList()}.
11111111
*
11121112
* {@link ng.$sce#what-trusted-context-types-are-supported- Find out more about the different context types}.
11131113
*

Diff for: src/ng/directive/ngInclude.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
* By default, the template URL is restricted to the same domain and protocol as the
1414
* application document. This is done by calling {@link $sce#getTrustedResourceUrl
1515
* $sce.getTrustedResourceUrl} on it. To load templates from other domains or protocols
16-
* you may either {@link ng.$sceDelegateProvider#resourceUrlWhitelist whitelist them} or
17-
* {@link $sce#trustAsResourceUrl wrap them} as trusted values. Refer to AngularJS's {@link
18-
* ng.$sce Strict Contextual Escaping}.
16+
* you may either add them to your {@link ng.$sceDelegateProvider#trustedResourceUrlList trusted
17+
* resource URL list} or {@link $sce#trustAsResourceUrl wrap them} as trusted values. Refer to
18+
* AngularJS's {@link ng.$sce Strict Contextual Escaping}.
1919
*
2020
* In addition, the browser's
2121
* [Same Origin Policy](https://code.google.com/p/browsersec/wiki/Part2#Same-origin_policy_for_XMLHttpRequest)

Diff for: src/ng/http.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ function $HttpProvider() {
965965
angular.module('httpExample', [])
966966
.config(['$sceDelegateProvider', function($sceDelegateProvider) {
967967
// We must whitelist the JSONP endpoint that we are using to show that we trust it
968-
$sceDelegateProvider.resourceUrlWhitelist([
968+
$sceDelegateProvider.trustedResourceUrlList([
969969
'self',
970970
'https://angularjs.org/**'
971971
]);
@@ -1223,7 +1223,7 @@ function $HttpProvider() {
12231223
* Note that, since JSONP requests are sensitive because the response is given full access to the browser,
12241224
* the url must be declared, via {@link $sce} as a trusted resource URL.
12251225
* You can trust a URL by adding it to the whitelist via
1226-
* {@link $sceDelegateProvider#resourceUrlWhitelist `$sceDelegateProvider.resourceUrlWhitelist`} or
1226+
* {@link $sceDelegateProvider#trustedResourceUrlList `$sceDelegateProvider.trustedResourceUrlList`} or
12271227
* by explicitly trusting the URL via {@link $sce#trustAsResourceUrl `$sce.trustAsResourceUrl(url)`}.
12281228
*
12291229
* You should avoid generating the URL for the JSONP request from user provided data.

0 commit comments

Comments
 (0)