Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit b775385

Browse files
committed
re-add link context, add tests for audio and source
1 parent 02fdd5c commit b775385

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

src/ng/compile.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -3160,7 +3160,9 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
31603160
}
31613161
// maction[xlink:href] can source SVG. It's not limited to <maction>.
31623162
} else if (attrNormalizedName === 'xlinkHref' ||
3163-
(tag === 'form' && attrNormalizedName === 'action')
3163+
(tag === 'form' && attrNormalizedName === 'action') ||
3164+
// links can be stylesheets or imports, which can run script in the current origin
3165+
(tag === 'link' && attrNormalizedName === 'href')
31643166
) {
31653167
return $sce.RESOURCE_URL;
31663168
}

test/ng/compileSpec.js

+19-16
Original file line numberDiff line numberDiff line change
@@ -10151,25 +10151,28 @@ describe('$compile', function() {
1015110151
expect(element.attr('src')).toEqual('http://example.com/image2.png');
1015210152
}));
1015310153

10154-
// Older IEs seem to reject the video tag with "Error: Not implemented"
10154+
// IE9 rejects the video / audio tag with "Error: Not implemented" and the source tag with
10155+
// "Unable to get value of the property 'childNodes': object is null or undefined"
1015510156
if (!msie || msie > 9) {
10156-
it('should NOT require trusted values for video src',
10157-
inject(function($rootScope, $compile, $sce) {
10158-
element = $compile('<video src="{{testUrl}}"></video>')($rootScope);
10159-
$rootScope.testUrl = 'http://example.com/image.mp4';
10160-
$rootScope.$digest();
10161-
expect(element.attr('src')).toEqual('http://example.com/image.mp4');
10157+
they('should NOT require trusted values for $prop src', ['video', 'audio', 'source'],
10158+
function(tag) {
10159+
inject(function($rootScope, $compile, $sce) {
10160+
element = $compile('<' + tag + ' src="{{testUrl}}"></' + tag + '>')($rootScope);
10161+
$rootScope.testUrl = 'http://example.com/image.mp4';
10162+
$rootScope.$digest();
10163+
expect(element.attr('src')).toEqual('http://example.com/image.mp4');
1016210164

10163-
// But it should accept trusted values anyway.
10164-
$rootScope.testUrl = $sce.trustAsUrl('http://example.com/image2.mp4');
10165-
$rootScope.$digest();
10166-
expect(element.attr('src')).toEqual('http://example.com/image2.mp4');
10165+
// But it should accept trusted values anyway.
10166+
$rootScope.testUrl = $sce.trustAsUrl('http://example.com/image2.mp4');
10167+
$rootScope.$digest();
10168+
expect(element.attr('src')).toEqual('http://example.com/image2.mp4');
1016710169

10168-
// and trustedResourceUrls for retrocompatibility
10169-
$rootScope.testUrl = $sce.trustAsResourceUrl('http://example.com/image3.mp4');
10170-
$rootScope.$digest();
10171-
expect(element.attr('src')).toEqual('http://example.com/image3.mp4');
10172-
}));
10170+
// and trustedResourceUrls for retrocompatibility
10171+
$rootScope.testUrl = $sce.trustAsResourceUrl('http://example.com/image3.mp4');
10172+
$rootScope.$digest();
10173+
expect(element.attr('src')).toEqual('http://example.com/image3.mp4');
10174+
});
10175+
});
1017310176
}
1017410177
});
1017510178

0 commit comments

Comments
 (0)