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

Commit 1278b7a

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

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
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-17
Original file line numberDiff line numberDiff line change
@@ -10152,25 +10152,27 @@ describe('$compile', function() {
1015210152
}));
1015310153

1015410154
// Older IEs seem to reject the video tag with "Error: Not implemented"
10155-
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');
10155+
// if (!msie || msie > 9) {
10156+
they('should NOT require trusted values for $prop src', ['video', 'audio', 'source'],
10157+
function(tag) {
10158+
inject(function($rootScope, $compile, $sce) {
10159+
element = $compile('<' + tag + ' src="{{testUrl}}"></' + tag + '>')($rootScope);
10160+
$rootScope.testUrl = 'http://example.com/image.mp4';
10161+
$rootScope.$digest();
10162+
expect(element.attr('src')).toEqual('http://example.com/image.mp4');
1016210163

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');
10164+
// But it should accept trusted values anyway.
10165+
$rootScope.testUrl = $sce.trustAsUrl('http://example.com/image2.mp4');
10166+
$rootScope.$digest();
10167+
expect(element.attr('src')).toEqual('http://example.com/image2.mp4');
1016710168

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-
}));
10173-
}
10169+
// and trustedResourceUrls for retrocompatibility
10170+
$rootScope.testUrl = $sce.trustAsResourceUrl('http://example.com/image3.mp4');
10171+
$rootScope.$digest();
10172+
expect(element.attr('src')).toEqual('http://example.com/image3.mp4');
10173+
});
10174+
});
10175+
// }
1017410176
});
1017510177

1017610178
describe('img[src] sanitization', function() {

0 commit comments

Comments
 (0)