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

Fix sce context #15039

Merged
merged 8 commits into from
Aug 26, 2016
Merged

Fix sce context #15039

merged 8 commits into from
Aug 26, 2016

Conversation

Narretz
Copy link
Contributor

@Narretz Narretz commented Aug 17, 2016

rebased and slightly tweaked #14019

rjamet added 6 commits August 17, 2016 22:19
…ack.

Previously, video, audio, and track sources were $sce.RESOURCE_URL. This is not justified as
no attacks are possible through these attributes as far as I can tell. This change is not
breaking, and uses of $sce.trustAsResourceUrl before assigning to src or ng-src attributes
will just be silently ignored.
Older msies reject my video element test, and format things better, no
more tests for video[src] contexts under a img[src] sanitization describe.
The context reduction didn't test retrocompatibility with trustAsResourceUrl(...) values.
Track files might contain CSS, and haven't been around for long. Keeping the
high security context as a precaution is justified.
Source src is only for media files (videos, audio, images), and present
no known script execution possibilities. We also don't expect new ones to pop up,
as this tags is only supported on recent browsers.
@@ -10152,6 +10151,32 @@ describe('$compile', function() {
expect(element.attr('src')).toEqual('http://example.com/image2.png');
}));

// Older IEs seem to reject the video tag with "Error: Not implemented"
// if (!msie || msie > 9) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems necessary. Tests are failing on IE9 without it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I was just checking if all of the elemnts fail

@@ -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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is that so? IE 9 supports video & audio elements.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

Copy link
Member

Choose a reason for hiding this comment

The 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 <video> and <audio>, obviously).

Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's because of this? videojs/video.js#290 (comment)

@Narretz
Copy link
Contributor Author

Narretz commented Aug 23, 2016

Can I merge this in the meantime or do you want this resolved first @mgol?

@mgol
Copy link
Member

mgol commented Aug 23, 2016

@Narretz Go ahead & merge, we can look into it later since it requires further investigation, apparently.

@rjamet
Copy link
Contributor

rjamet commented Aug 23, 2016

Hey, sorry, I left for a few days right when you started the conversation :/ As you spotted, there won't be a $sce context anymore for these three. I think having no sanitization there is fine since no browser will execute script there, but if you want consistency you'd just need to add them where sanitization happens: https://github.com/angular/angular.js/blob/master/src/ng/compile.js#L1631 .

Also, I didn't have time to update this PR, but for Angular 2, we ended up putting track src in the same basket. I was a little concerned about the video subset of CSS, but after looking at the specs and testings, it looks harmless (angular/angular#10187)

@Narretz
Copy link
Contributor Author

Narretz commented Aug 24, 2016

@rjamet Ok, I will then re-add track and merge the PR

@Narretz Narretz merged commit 4853201 into angular:master Aug 26, 2016
Narretz pushed a commit that referenced this pull request Aug 26, 2016
…ce, track

Previously, video, audio, source, and track sources were $sce.RESOURCE_URL. This is not justified as
no attacks (script execution) are possible through these attributes as far as we can tell.
Angular2 also uses the same categorization.

This change is not breaking, and uses of $sce.trustAsResourceUrl before assigning to src or ng-src
attributes will just be silently ignored.

This has also been given a LGTM by @mprobst via email.

Commit 4853201 on the master branch contains the same changes, but
is missing this commit description.

This commit does not backport the BC introduced in 04cad41.

PR (#15039)
Closes #14019
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
…ce, track

Previously, video, audio, source, and track sources were $sce.RESOURCE_URL. This is not justified as
no attacks (script execution) are possible through these attributes as far as we can tell.
Angular2 also uses the same categorization.

This change is not breaking, and uses of $sce.trustAsResourceUrl before assigning to src or ng-src
attributes will just be silently ignored.

This has also been given a LGTM by @mprobst via email.

Commit 4853201 on the master branch contains the same changes, but
is missing this commit description.

This commit does not backport the BC introduced in 04cad41.

PR (angular#15039)
Closes angular#14019
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
…ce, track

Previously, video, audio, source, and track sources were $sce.RESOURCE_URL. This is not justified as
no attacks (script execution) are possible through these attributes as far as we can tell.
Angular2 also uses the same categorization.

This change is not breaking, and uses of $sce.trustAsResourceUrl before assigning to src or ng-src
attributes will just be silently ignored.

This has also been given a LGTM by @mprobst via email.

Commit 4853201 on the master branch contains the same changes, but
is missing this commit description.

This commit does not backport the BC introduced in 04cad41.

PR (angular#15039)
Closes angular#14019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants