From 0bf0570505e41be266beaa1ccd0266aaed0c3cfb Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Thu, 8 Aug 2013 10:22:32 -0700 Subject: docs(minErr): rename sce/isecrurl to sce/insecurl --- docs/content/error/insecurl.ngdoc | 30 ++++++++++++++++++++++++++++++ docs/content/error/sce/isecrurl.ngdoc | 30 ------------------------------ src/ng/sce.js | 2 +- test/ng/compileSpec.js | 8 ++++---- test/ng/directive/booleanAttrsSpec.js | 2 +- test/ng/directive/ngSrcSpec.js | 6 +++--- test/ng/sceSpecs.js | 14 +++++++------- test/ngRoute/routeSpec.js | 2 +- 8 files changed, 47 insertions(+), 47 deletions(-) create mode 100644 docs/content/error/insecurl.ngdoc delete mode 100644 docs/content/error/sce/isecrurl.ngdoc diff --git a/docs/content/error/insecurl.ngdoc b/docs/content/error/insecurl.ngdoc new file mode 100644 index 00000000..a4ba5d92 --- /dev/null +++ b/docs/content/error/insecurl.ngdoc @@ -0,0 +1,30 @@ +@ngdoc error +@name $sce:insecurl +@fullName Blocked loading an untrusted resource +@description + +AngularJS' {@link api/ng.$sce#strictcontextualescaping Strict Contextual Escaping +(SCE)} mode (enabled by default) has blocked loading a resource from an insecure URL. + +Typically, this would occur if you're attempting to load an Angular template from a different +domain. It's also possible that a custom directive threw this error for a similar reason. + +Angular only loads templates from trusted URLs (by calling {@link api/ng.$sce#getTrustedResourceUrl +$sce.getTrustedResourceUrl} on the template URL.). + +By default, only URLs to the same domain with the same protocol as the application document are +considered to be trusted. + +The {@link api/ng.directive:ngInclude ng-include} directive and {@link guide/directive directives} +that specify a `templateUrl` require a trusted resource URL. + +To load templates from other domains and/or protocols, either adjust the {@link +api/ng.$sceDelegateProvider#resourceUrlWhitelist whitelist}/ {@link +api/ng.$sceDelegateProvider#resourceUrlBlacklist blacklist} or wrap the URL with a call to {@link +api/ng.$sce#trustAsResourceUrl $sce.trustAsResourceUrl}. + +**Note**: The browser's {@link +https://code.google.com/p/browsersec/wiki/Part2#Same-origin_policy_for_XMLHttpRequest Same Origin +Policy} and {@link http://www.w3.org/TR/cors/ Cross-Origin Resource Sharing (CORS)} policy apply +that may further restrict whether the template is successfully loaded. (e.g. neither cross-domain +requests won't work on all browsers nor `file://` requests on some browsers) diff --git a/docs/content/error/sce/isecrurl.ngdoc b/docs/content/error/sce/isecrurl.ngdoc deleted file mode 100644 index c5a5445d..00000000 --- a/docs/content/error/sce/isecrurl.ngdoc +++ /dev/null @@ -1,30 +0,0 @@ -@ngdoc error -@name $sce:isecrurl -@fullName Blocked loading an untrusted resource -@description - -AngularJS' {@link api/ng.$sce#strictcontextualescaping Strict Contextual Escaping -(SCE)} mode (enabled by default) has blocked loading a resource from an insecure URL. - -Typically, this would occur if you're attempting to load an Angular template from a different -domain. It's also possible that a custom directive threw this error for a similar reason. - -Angular only loads templates from trusted URLs (by calling {@link api/ng.$sce#getTrustedResourceUrl -$sce.getTrustedResourceUrl} on the template URL.). - -By default, only URLs to the same domain with the same protocol as the application document are -considered to be trusted. - -The {@link api/ng.directive:ngInclude ng-include} directive and {@link guide/directive directives} -that specify a `templateUrl` require a trusted resource URL. - -To load templates from other domains and/or protocols, either adjust the {@link -api/ng.$sceDelegateProvider#resourceUrlWhitelist whitelist}/ {@link -api/ng.$sceDelegateProvider#resourceUrlBlacklist blacklist} or wrap the URL with a call to {@link -api/ng.$sce#trustAsResourceUrl $sce.trustAsResourceUrl}. - -**Note**: The browser's {@link -https://code.google.com/p/browsersec/wiki/Part2#Same-origin_policy_for_XMLHttpRequest Same Origin -Policy} and {@link http://www.w3.org/TR/cors/ Cross-Origin Resource Sharing (CORS)} policy apply -that may further restrict whether the template is successfully loaded. (e.g. neither cross-domain -requests won't work on all browsers nor `file://` requests on some browsers) diff --git a/src/ng/sce.js b/src/ng/sce.js index f043c7d8..cf9cce58 100644 --- a/src/ng/sce.js +++ b/src/ng/sce.js @@ -301,7 +301,7 @@ function $SceDelegateProvider() { if (isResourceUrlAllowedByPolicy(maybeTrusted)) { return maybeTrusted; } else { - throw $sceMinErr('isecrurl', + throw $sceMinErr('insecurl', 'Blocked loading resource from url not allowed by $sceDelegate policy. URL: {0}', maybeTrusted.toString()); } } else if (type === SCE_CONTEXTS.HTML) { diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index 5dfad4be..25d2db35 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -748,7 +748,7 @@ describe('$compile', function() { expect(function() { $templateCache.put('http://example.com/should-not-load.html', 'Should not load even if in cache.'); $compile('
')($rootScope); - }).toThrow('[$sce:isecrurl] Blocked loading resource from url not allowed by $sceDelegate policy. URL: http://example.com/should-not-load.html'); + }).toThrow('[$sce:insecurl] Blocked loading resource from url not allowed by $sceDelegate policy. URL: http://example.com/should-not-load.html'); })); it('should load cross domain templates when trusted', inject( @@ -3063,7 +3063,7 @@ describe('$compile', function() { element = $compile('')($rootScope); $rootScope.testUrl = "http://a.different.domain.example.com"; expect(function() { $rootScope.$apply() }).toThrow( - "[$interpolate:interr] Can't interpolate: {{testUrl}}\nError: [$sce:isecrurl] Blocked " + + "[$interpolate:interr] Can't interpolate: {{testUrl}}\nError: [$sce:insecurl] Blocked " + "loading resource from url not allowed by $sceDelegate policy. URL: " + "http://a.different.domain.example.com"); })); @@ -3072,7 +3072,7 @@ describe('$compile', function() { element = $compile('')($rootScope); $rootScope.testUrl = "javascript:alert(1);"; expect(function() { $rootScope.$apply() }).toThrow( - "[$interpolate:interr] Can't interpolate: {{testUrl}}\nError: [$sce:isecrurl] Blocked " + + "[$interpolate:interr] Can't interpolate: {{testUrl}}\nError: [$sce:insecurl] Blocked " + "loading resource from url not allowed by $sceDelegate policy. URL: " + "javascript:alert(1);"); })); @@ -3081,7 +3081,7 @@ describe('$compile', function() { element = $compile('')($rootScope); $rootScope.testUrl = $sce.trustAsUrl("javascript:doTrustedStuff()"); expect($rootScope.$apply).toThrow( - "[$interpolate:interr] Can't interpolate: {{testUrl}}\nError: [$sce:isecrurl] Blocked " + + "[$interpolate:interr] Can't interpolate: {{testUrl}}\nError: [$sce:insecurl] Blocked " + "loading resource from url not allowed by $sceDelegate policy. URL: javascript:doTrustedStuff()"); })); diff --git a/test/ng/directive/booleanAttrsSpec.js b/test/ng/directive/booleanAttrsSpec.js index 93e8cc20..0b0c290d 100644 --- a/test/ng/directive/booleanAttrsSpec.js +++ b/test/ng/directive/booleanAttrsSpec.js @@ -163,7 +163,7 @@ describe('ngSrc', function() { }); element.attr('src'); }).toThrow( - "[$interpolate:interr] Can't interpolate: {{id}}\nError: [$sce:isecrurl] Blocked " + + "[$interpolate:interr] Can't interpolate: {{id}}\nError: [$sce:insecurl] Blocked " + "loading resource from url not allowed by $sceDelegate policy. URL: http://somewhere"); })); diff --git a/test/ng/directive/ngSrcSpec.js b/test/ng/directive/ngSrcSpec.js index 23ace7ee..2fb99eab 100644 --- a/test/ng/directive/ngSrcSpec.js +++ b/test/ng/directive/ngSrcSpec.js @@ -27,7 +27,7 @@ describe('ngSrc', function() { element = $compile('')($rootScope); $rootScope.testUrl = "http://a.different.domain.example.com"; expect(function() { $rootScope.$apply() }).toThrow( - "[$interpolate:interr] Can't interpolate: {{testUrl}}\nError: [$sce:isecrurl] Blocked " + + "[$interpolate:interr] Can't interpolate: {{testUrl}}\nError: [$sce:insecurl] Blocked " + "loading resource from url not allowed by $sceDelegate policy. URL: " + "http://a.different.domain.example.com"); })); @@ -36,7 +36,7 @@ describe('ngSrc', function() { element = $compile('')($rootScope); $rootScope.testUrl = "javascript:alert(1);"; expect(function() { $rootScope.$apply() }).toThrow( - "[$interpolate:interr] Can't interpolate: {{testUrl}}\nError: [$sce:isecrurl] Blocked " + + "[$interpolate:interr] Can't interpolate: {{testUrl}}\nError: [$sce:insecurl] Blocked " + "loading resource from url not allowed by $sceDelegate policy. URL: " + "javascript:alert(1);"); })); @@ -45,7 +45,7 @@ describe('ngSrc', function() { element = $compile('')($rootScope); $rootScope.testUrl = $sce.trustAsUrl("javascript:doTrustedStuff()"); expect($rootScope.$apply).toThrow( - "[$interpolate:interr] Can't interpolate: {{testUrl}}\nError: [$sce:isecrurl] Blocked " + + "[$interpolate:interr] Can't interpolate: {{testUrl}}\nError: [$sce:insecurl] Blocked " + "loading resource from url not allowed by $sceDelegate policy. URL: " + "javascript:doTrustedStuff()"); })); diff --git a/test/ng/sceSpecs.js b/test/ng/sceSpecs.js index 6157fc17..9be794fb 100644 --- a/test/ng/sceSpecs.js +++ b/test/ng/sceSpecs.js @@ -280,7 +280,7 @@ describe('SCE', function() { blackList: [] }, function($sce) { expect(function() { $sce.getTrustedResourceUrl('#'); }).toThrow( - '[$sce:isecrurl] Blocked loading resource from url not allowed by $sceDelegate policy. URL: #'); + '[$sce:insecurl] Blocked loading resource from url not allowed by $sceDelegate policy. URL: #'); })); it('should match against normalized urls', runTest( @@ -289,7 +289,7 @@ describe('SCE', function() { blackList: [] }, function($sce) { expect(function() { $sce.getTrustedResourceUrl('foo'); }).toThrow( - '[$sce:isecrurl] Blocked loading resource from url not allowed by $sceDelegate policy. URL: foo'); + '[$sce:insecurl] Blocked loading resource from url not allowed by $sceDelegate policy. URL: foo'); })); it('should support custom regex', runTest( @@ -299,7 +299,7 @@ describe('SCE', function() { }, function($sce) { expect($sce.getTrustedResourceUrl('http://example.com/foo')).toEqual('http://example.com/foo'); expect(function() { $sce.getTrustedResourceUrl('https://example.com/foo'); }).toThrow( - '[$sce:isecrurl] Blocked loading resource from url not allowed by $sceDelegate policy. URL: https://example.com/foo'); + '[$sce:insecurl] Blocked loading resource from url not allowed by $sceDelegate policy. URL: https://example.com/foo'); })); it('should support the special string "self" in whitelist', runTest( @@ -316,7 +316,7 @@ describe('SCE', function() { blackList: ['self'] }, function($sce) { expect(function() { $sce.getTrustedResourceUrl('foo'); }).toThrow( - '[$sce:isecrurl] Blocked loading resource from url not allowed by $sceDelegate policy. URL: foo'); + '[$sce:insecurl] Blocked loading resource from url not allowed by $sceDelegate policy. URL: foo'); })); it('should have blacklist override the whitelist', runTest( @@ -325,7 +325,7 @@ describe('SCE', function() { blackList: ['self'] }, function($sce) { expect(function() { $sce.getTrustedResourceUrl('foo'); }).toThrow( - '[$sce:isecrurl] Blocked loading resource from url not allowed by $sceDelegate policy. URL: foo'); + '[$sce:insecurl] Blocked loading resource from url not allowed by $sceDelegate policy. URL: foo'); })); it('should support multiple items in both lists', runTest( @@ -337,9 +337,9 @@ describe('SCE', function() { expect($sce.getTrustedResourceUrl('http://example.com/1')).toEqual('http://example.com/1'); expect($sce.getTrustedResourceUrl('http://example.com/2')).toEqual('http://example.com/2'); expect(function() { $sce.getTrustedResourceUrl('http://example.com/3'); }).toThrow( - '[$sce:isecrurl] Blocked loading resource from url not allowed by $sceDelegate policy. URL: http://example.com/3'); + '[$sce:insecurl] Blocked loading resource from url not allowed by $sceDelegate policy. URL: http://example.com/3'); expect(function() { $sce.getTrustedResourceUrl('open_redirect'); }).toThrow( - '[$sce:isecrurl] Blocked loading resource from url not allowed by $sceDelegate policy. URL: open_redirect'); + '[$sce:insecurl] Blocked loading resource from url not allowed by $sceDelegate policy. URL: open_redirect'); })); }); diff --git a/test/ngRoute/routeSpec.js b/test/ngRoute/routeSpec.js index 13d149a1..29c2b798 100644 --- a/test/ngRoute/routeSpec.js +++ b/test/ngRoute/routeSpec.js @@ -520,7 +520,7 @@ describe('$route', function() { $location.path('/foo'); expect(function() { $rootScope.$digest(); - }).toThrow('[$sce:isecrurl] Blocked loading resource from url not allowed by $sceDelegate policy. URL: http://example.com/foo.html'); + }).toThrow('[$sce:insecurl] Blocked loading resource from url not allowed by $sceDelegate policy. URL: http://example.com/foo.html'); }); }); -- cgit v1.2.3