@@ -7215,6 +7215,54 @@ describe('$compile', function() {
72157215 } ) ;
72167216 } ) ;
72177217
7218+ it ( 'should use $$sanitizeUri when declared via ng-href' , function ( ) {
7219+ var $$sanitizeUri = jasmine . createSpy ( '$$sanitizeUri' ) ;
7220+ module ( function ( $provide ) {
7221+ $provide . value ( '$$sanitizeUri' , $$sanitizeUri ) ;
7222+ } ) ;
7223+ inject ( function ( $compile , $rootScope ) {
7224+ element = $compile ( '<a ng-href="{{testUrl}}"></a>' ) ( $rootScope ) ;
7225+ $rootScope . testUrl = "someUrl" ;
7226+
7227+ $$sanitizeUri . andReturn ( 'someSanitizedUrl' ) ;
7228+ $rootScope . $apply ( ) ;
7229+ expect ( element . attr ( 'href' ) ) . toBe ( 'someSanitizedUrl' ) ;
7230+ expect ( $$sanitizeUri ) . toHaveBeenCalledWith ( $rootScope . testUrl , false ) ;
7231+ } ) ;
7232+ } ) ;
7233+
7234+ it ( 'should use $$sanitizeUri when working with svg and xlink:href' , function ( ) {
7235+ var $$sanitizeUri = jasmine . createSpy ( '$$sanitizeUri' ) ;
7236+ module ( function ( $provide ) {
7237+ $provide . value ( '$$sanitizeUri' , $$sanitizeUri ) ;
7238+ } ) ;
7239+ inject ( function ( $compile , $rootScope ) {
7240+ element = $compile ( '<svg><a xlink:href="" ng-href="{{ testUrl }}"></a></svg>' ) ( $rootScope ) ;
7241+ $rootScope . testUrl = "evilUrl" ;
7242+
7243+ $$sanitizeUri . andReturn ( 'someSanitizedUrl' ) ;
7244+ $rootScope . $apply ( ) ;
7245+ expect ( element . find ( 'a' ) . prop ( 'href' ) . baseVal ) . toBe ( 'someSanitizedUrl' ) ;
7246+ expect ( $$sanitizeUri ) . toHaveBeenCalledWith ( $rootScope . testUrl , false ) ;
7247+ } ) ;
7248+ } ) ;
7249+
7250+
7251+ it ( 'should use $$sanitizeUri when working with svg and xlink:href' , function ( ) {
7252+ var $$sanitizeUri = jasmine . createSpy ( '$$sanitizeUri' ) ;
7253+ module ( function ( $provide ) {
7254+ $provide . value ( '$$sanitizeUri' , $$sanitizeUri ) ;
7255+ } ) ;
7256+ inject ( function ( $compile , $rootScope ) {
7257+ element = $compile ( '<svg><a xlink:href="" ng-href="{{ testUrl }}"></a></svg>' ) ( $rootScope ) ;
7258+ $rootScope . testUrl = "evilUrl" ;
7259+
7260+ $$sanitizeUri . andReturn ( 'someSanitizedUrl' ) ;
7261+ $rootScope . $apply ( ) ;
7262+ expect ( element . find ( 'a' ) . prop ( 'href' ) . baseVal ) . toBe ( 'someSanitizedUrl' ) ;
7263+ expect ( $$sanitizeUri ) . toHaveBeenCalledWith ( $rootScope . testUrl , false ) ;
7264+ } ) ;
7265+ } ) ;
72187266 } ) ;
72197267
72207268 describe ( 'interpolation on HTML DOM event handler attributes onclick, onXYZ, formaction' , function ( ) {
0 commit comments