-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Fix sce context #15039
Fix sce context #15039
Changes from 7 commits
ff090d7
5839dce
ec31b3d
02ce357
5115275
02fdd5c
b775385
e9f2f1c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10138,8 +10138,7 @@ describe('$compile', function() { | |
}); | ||
}); | ||
|
||
|
||
describe('img[src] sanitization', function() { | ||
describe('*[src] context requirement', function() { | ||
|
||
it('should NOT require trusted values for img src', inject(function($rootScope, $compile, $sce) { | ||
element = $compile('<img src="{{testUrl}}"></img>')($rootScope); | ||
|
@@ -10152,6 +10151,33 @@ describe('$compile', function() { | |
expect(element.attr('src')).toEqual('http://example.com/image2.png'); | ||
})); | ||
|
||
// IE9 rejects the video / audio tag with "Error: Not implemented" and the source tag with | ||
// "Unable to get value of the property 'childNodes': object is null or undefined" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is that so? IE 9 supports There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But not if we try to do it like we do in the test. It's possible that we need different HTML for it to work: http://stackoverflow.com/questions/7358689/audio-tag-not-working-in-ie9 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The OP answered that adding a DOCTYPE helped. Do our test cases not have a DOCTYPE? If that's the case we should definitely add them, we should make sure all our tests are running in standards mode, not quirks mode that we don't even officially support AFAIK. All IE versions older than 10 in quirks mode invoke a separate engine simulating IE 5.5 and, as a consequence, missing features from newer versions (including There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've looked at a couple of pages used for e2e tests and they all have a DOCTYPE. The template used by Karma also specifies a DOCTYPE. So this shouldn't be a problem. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it's because of this? videojs/video.js#290 (comment) |
||
if (!msie || msie > 9) { | ||
they('should NOT require trusted values for $prop src', ['video', 'audio', 'source'], | ||
function(tag) { | ||
inject(function($rootScope, $compile, $sce) { | ||
element = $compile('<' + tag + ' src="{{testUrl}}"></' + tag + '>')($rootScope); | ||
$rootScope.testUrl = 'http://example.com/image.mp4'; | ||
$rootScope.$digest(); | ||
expect(element.attr('src')).toEqual('http://example.com/image.mp4'); | ||
|
||
// But it should accept trusted values anyway. | ||
$rootScope.testUrl = $sce.trustAsUrl('http://example.com/image2.mp4'); | ||
$rootScope.$digest(); | ||
expect(element.attr('src')).toEqual('http://example.com/image2.mp4'); | ||
|
||
// and trustedResourceUrls for retrocompatibility | ||
$rootScope.testUrl = $sce.trustAsResourceUrl('http://example.com/image3.mp4'); | ||
$rootScope.$digest(); | ||
expect(element.attr('src')).toEqual('http://example.com/image3.mp4'); | ||
}); | ||
}); | ||
} | ||
}); | ||
|
||
describe('img[src] sanitization', function() { | ||
|
||
it('should not sanitize attributes other than src', inject(function($compile, $rootScope) { | ||
element = $compile('<img title="{{testUrl}}"></img>')($rootScope); | ||
$rootScope.testUrl = 'javascript:doEvilStuff()'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the same true for
<audio/video/source src=
?/cc @rjamet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that depends on what "sanitize" means. The important part seems to be that in the src attribute, no script execution is possible, that's why we can remove the url context. But Idk if that means sanitization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These three won't be sanitized, but as far as we know there's no browser that both supports these tags, and runs javascript: URLs there.