This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +13
-8
lines changed
2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -1458,15 +1458,19 @@ function allowAutoBootstrap(document) {
1458
1458
return false ;
1459
1459
}
1460
1460
1461
- var srcs = [ script . getAttribute ( 'src' ) , script . getAttribute ( 'href' ) , script . getAttribute ( 'xlink:href' ) ] ;
1461
+ var attributes = script . attributes ;
1462
+ var srcs = [ attributes . getNamedItem ( 'src' ) , attributes . getNamedItem ( 'href' ) , attributes . getNamedItem ( 'xlink:href' ) ] ;
1462
1463
1463
1464
return srcs . every ( function ( src ) {
1464
1465
if ( ! src ) {
1465
1466
return true ;
1466
1467
}
1468
+ if ( ! src . value ) {
1469
+ return false ;
1470
+ }
1467
1471
1468
1472
var link = document . createElement ( 'a' ) ;
1469
- link . href = src ;
1473
+ link . href = src . value ;
1470
1474
1471
1475
if ( document . location . origin === link . origin ) {
1472
1476
// Same-origin resources are always allowed, even for non-whitelisted schemes.
Original file line number Diff line number Diff line change @@ -1741,16 +1741,17 @@ describe('angular', function() {
1741
1741
expect ( allowAutoBootstrap ( createFakeDoc ( { src : protocol + '//something-else' } , protocol ) ) ) . toBe ( false ) ;
1742
1742
} ) ;
1743
1743
1744
- it ( 'should bootstrap from a script with empty or no source (e.g. src, href or xlink:href attributes)' , function ( ) {
1744
+ it ( 'should bootstrap from a script with no source (e.g. src, href or xlink:href attributes)' , function ( ) {
1745
1745
1746
1746
expect ( allowAutoBootstrap ( createFakeDoc ( { src : null } ) ) ) . toBe ( true ) ;
1747
- expect ( allowAutoBootstrap ( createFakeDoc ( { src : '' } ) ) ) . toBe ( true ) ;
1748
-
1749
1747
expect ( allowAutoBootstrap ( createFakeDoc ( { href : null } ) ) ) . toBe ( true ) ;
1750
- expect ( allowAutoBootstrap ( createFakeDoc ( { href : '' } ) ) ) . toBe ( true ) ;
1751
-
1752
1748
expect ( allowAutoBootstrap ( createFakeDoc ( { 'xlink:href' : null } ) ) ) . toBe ( true ) ;
1753
- expect ( allowAutoBootstrap ( createFakeDoc ( { 'xlink:href' : '' } ) ) ) . toBe ( true ) ;
1749
+ } ) ;
1750
+
1751
+ it ( 'should not bootstrap from a script with an empty source (e.g. `src=""`)' , function ( ) {
1752
+ expect ( allowAutoBootstrap ( createFakeDoc ( { src : '' } ) ) ) . toBe ( false ) ;
1753
+ expect ( allowAutoBootstrap ( createFakeDoc ( { href : '' } ) ) ) . toBe ( false ) ;
1754
+ expect ( allowAutoBootstrap ( createFakeDoc ( { 'xlink:href' : '' } ) ) ) . toBe ( false ) ;
1754
1755
} ) ;
1755
1756
1756
1757
You can’t perform that action at this time.
0 commit comments