@@ -6322,6 +6322,54 @@ describe('$compile', function() {
6322
6322
} ) ;
6323
6323
} ) ;
6324
6324
6325
+ it ( 'should use $$sanitizeUri when declared via ng-href' , function ( ) {
6326
+ var $$sanitizeUri = jasmine . createSpy ( '$$sanitizeUri' ) ;
6327
+ module ( function ( $provide ) {
6328
+ $provide . value ( '$$sanitizeUri' , $$sanitizeUri ) ;
6329
+ } ) ;
6330
+ inject ( function ( $compile , $rootScope ) {
6331
+ element = $compile ( '<a ng-href="{{testUrl}}"></a>' ) ( $rootScope ) ;
6332
+ $rootScope . testUrl = "someUrl" ;
6333
+
6334
+ $$sanitizeUri . andReturn ( 'someSanitizedUrl' ) ;
6335
+ $rootScope . $apply ( ) ;
6336
+ expect ( element . attr ( 'href' ) ) . toBe ( 'someSanitizedUrl' ) ;
6337
+ expect ( $$sanitizeUri ) . toHaveBeenCalledWith ( $rootScope . testUrl , false ) ;
6338
+ } ) ;
6339
+ } ) ;
6340
+
6341
+ it ( 'should use $$sanitizeUri when working with svg and xlink:href' , function ( ) {
6342
+ var $$sanitizeUri = jasmine . createSpy ( '$$sanitizeUri' ) ;
6343
+ module ( function ( $provide ) {
6344
+ $provide . value ( '$$sanitizeUri' , $$sanitizeUri ) ;
6345
+ } ) ;
6346
+ inject ( function ( $compile , $rootScope ) {
6347
+ element = $compile ( '<svg><a xlink:href="" ng-href="{{ testUrl }}"></a></svg>' ) ( $rootScope ) ;
6348
+ $rootScope . testUrl = "evilUrl" ;
6349
+
6350
+ $$sanitizeUri . andReturn ( 'someSanitizedUrl' ) ;
6351
+ $rootScope . $apply ( ) ;
6352
+ expect ( element . find ( 'a' ) . prop ( 'href' ) . baseVal ) . toBe ( 'someSanitizedUrl' ) ;
6353
+ expect ( $$sanitizeUri ) . toHaveBeenCalledWith ( $rootScope . testUrl , false ) ;
6354
+ } ) ;
6355
+ } ) ;
6356
+
6357
+
6358
+ it ( 'should use $$sanitizeUri when working with svg and xlink:href' , function ( ) {
6359
+ var $$sanitizeUri = jasmine . createSpy ( '$$sanitizeUri' ) ;
6360
+ module ( function ( $provide ) {
6361
+ $provide . value ( '$$sanitizeUri' , $$sanitizeUri ) ;
6362
+ } ) ;
6363
+ inject ( function ( $compile , $rootScope ) {
6364
+ element = $compile ( '<svg><a xlink:href="" ng-href="{{ testUrl }}"></a></svg>' ) ( $rootScope ) ;
6365
+ $rootScope . testUrl = "evilUrl" ;
6366
+
6367
+ $$sanitizeUri . andReturn ( 'someSanitizedUrl' ) ;
6368
+ $rootScope . $apply ( ) ;
6369
+ expect ( element . find ( 'a' ) . prop ( 'href' ) . baseVal ) . toBe ( 'someSanitizedUrl' ) ;
6370
+ expect ( $$sanitizeUri ) . toHaveBeenCalledWith ( $rootScope . testUrl , false ) ;
6371
+ } ) ;
6372
+ } ) ;
6325
6373
} ) ;
6326
6374
6327
6375
describe ( 'interpolation on HTML DOM event handler attributes onclick, onXYZ, formaction' , function ( ) {
0 commit comments