This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -69,9 +69,15 @@ function $$SanitizeUriProvider() {
69
69
70
70
this . $get = function ( ) {
71
71
return function sanitizeUri ( uri , isMediaUrl ) {
72
+ if ( ! uri ) return uri ;
72
73
var regex = isMediaUrl ? imgSrcSanitizationWhitelist : aHrefSanitizationWhitelist ;
73
74
var normalizedVal ;
74
- normalizedVal = urlResolve ( uri && uri . trim ( ) ) . href ;
75
+ try {
76
+ normalizedVal = urlResolve ( uri . trim ( ) ) . href ;
77
+ } catch ( e ) {
78
+ console . log ( uri ) ;
79
+ throw e ;
80
+ }
75
81
if ( normalizedVal !== '' && ! normalizedVal . match ( regex ) ) {
76
82
return 'unsafe:' + normalizedVal ;
77
83
}
Original file line number Diff line number Diff line change @@ -11173,13 +11173,13 @@ describe('$compile', function() {
11173
11173
$rootScope . $digest ( ) ;
11174
11174
expect ( element . attr ( 'src' ) ) . toEqual ( 'unsafe:untrusted:foo();ponies' ) ;
11175
11175
11176
- element = $compile ( '<img src="http://{{testUrl }}"></img>' ) ( $rootScope ) ;
11177
- $rootScope . testUrl = $sce . trustAsUrl ( 'untrusted:foo() ;' ) ;
11176
+ element = $compile ( '<img src="http://{{testUrl2 }}"></img>' ) ( $rootScope ) ;
11177
+ $rootScope . testUrl2 = $sce . trustAsUrl ( 'xyz ;' ) ;
11178
11178
$rootScope . $digest ( ) ;
11179
- expect ( element . attr ( 'src' ) ) . toEqual ( 'http://untrusted:foo() ;' ) ;
11179
+ expect ( element . attr ( 'src' ) ) . toEqual ( 'http://xyz ;' ) ;
11180
11180
11181
- element = $compile ( '<img src="{{testUrl }}{{testUrl }}"></img>' ) ( $rootScope ) ;
11182
- $rootScope . testUrl = $sce . trustAsUrl ( 'untrusted:foo();' ) ;
11181
+ element = $compile ( '<img src="{{testUrl3 }}{{testUrl3 }}"></img>' ) ( $rootScope ) ;
11182
+ $rootScope . testUrl3 = $sce . trustAsUrl ( 'untrusted:foo();' ) ;
11183
11183
$rootScope . $digest ( ) ;
11184
11184
expect ( element . attr ( 'src' ) ) . toEqual ( 'unsafe:untrusted:foo();untrusted:foo();' ) ;
11185
11185
} ) ) ;
@@ -11220,7 +11220,7 @@ describe('$compile', function() {
11220
11220
expect ( element . attr ( 'src' ) ) . toEqual ( 'someSanitizedUrl' ) ;
11221
11221
11222
11222
element = $compile ( '<img src="http://{{testUrl}}"></img>' ) ( $rootScope ) ;
11223
- $rootScope . testUrl = $sce . trustAsUrl ( 'javascript:foo(); ' ) ;
11223
+ $rootScope . testUrl = $sce . trustAsUrl ( 'xyz ' ) ;
11224
11224
$rootScope . $digest ( ) ;
11225
11225
expect ( element . attr ( 'src' ) ) . toEqual ( 'someSanitizedUrl' ) ;
11226
11226
} ) ;
You can’t perform that action at this time.
0 commit comments