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 @@ -1543,15 +1543,19 @@ function allowAutoBootstrap(document) {
1543
1543
return false ;
1544
1544
}
1545
1545
1546
- var srcs = [ script . getAttribute ( 'src' ) , script . getAttribute ( 'href' ) , script . getAttribute ( 'xlink:href' ) ] ;
1546
+ var attributes = script . attributes ;
1547
+ var srcs = [ attributes . getNamedItem ( 'src' ) , attributes . getNamedItem ( 'href' ) , attributes . getNamedItem ( 'xlink:href' ) ] ;
1547
1548
1548
1549
return srcs . every ( function ( src ) {
1549
1550
if ( ! src ) {
1550
1551
return true ;
1551
1552
}
1553
+ if ( ! src . value ) {
1554
+ return false ;
1555
+ }
1552
1556
1553
1557
var link = document . createElement ( 'a' ) ;
1554
- link . href = src ;
1558
+ link . href = src . value ;
1555
1559
1556
1560
if ( document . location . origin === link . origin ) {
1557
1561
// Same-origin resources are always allowed, even for non-whitelisted schemes.
Original file line number Diff line number Diff line change @@ -1752,16 +1752,17 @@ describe('angular', function() {
1752
1752
expect ( allowAutoBootstrap ( createFakeDoc ( { src : protocol + '//something-else' } , protocol ) ) ) . toBe ( false ) ;
1753
1753
} ) ;
1754
1754
1755
- it ( 'should bootstrap from a script with empty or no source (e.g. src, href or xlink:href attributes)' , function ( ) {
1755
+ it ( 'should bootstrap from a script with no source (e.g. src, href or xlink:href attributes)' , function ( ) {
1756
1756
1757
1757
expect ( allowAutoBootstrap ( createFakeDoc ( { src : null } ) ) ) . toBe ( true ) ;
1758
- expect ( allowAutoBootstrap ( createFakeDoc ( { src : '' } ) ) ) . toBe ( true ) ;
1759
-
1760
1758
expect ( allowAutoBootstrap ( createFakeDoc ( { href : null } ) ) ) . toBe ( true ) ;
1761
- expect ( allowAutoBootstrap ( createFakeDoc ( { href : '' } ) ) ) . toBe ( true ) ;
1762
-
1763
1759
expect ( allowAutoBootstrap ( createFakeDoc ( { 'xlink:href' : null } ) ) ) . toBe ( true ) ;
1764
- expect ( allowAutoBootstrap ( createFakeDoc ( { 'xlink:href' : '' } ) ) ) . toBe ( true ) ;
1760
+ } ) ;
1761
+
1762
+ it ( 'should not bootstrap from a script with an empty source (e.g. `src=""`)' , function ( ) {
1763
+ expect ( allowAutoBootstrap ( createFakeDoc ( { src : '' } ) ) ) . toBe ( false ) ;
1764
+ expect ( allowAutoBootstrap ( createFakeDoc ( { href : '' } ) ) ) . toBe ( false ) ;
1765
+ expect ( allowAutoBootstrap ( createFakeDoc ( { 'xlink:href' : '' } ) ) ) . toBe ( false ) ;
1765
1766
} ) ;
1766
1767
1767
1768
You can’t perform that action at this time.
0 commit comments