This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat($sce): handle URLs through the $sce service
Thanks to @rjamet for the original work on this feature. This is a large patch to handle URLs with the $sce service, similarly to HTML context. However, to keep rough compatibility with existing apps, we need to allow URL-context concatenation, since previously $sce contexts prevented sanitization. There's now a set of special contexts (defined in $interpolate) that allow concatenation, in a roughly intuitive way: * Trusted types alone are trusted, e.g. `"{{safeType}}"` will not be sanitized. * Any concatenation of values results in a non-trusted type that will be handled by `getTrusted` once the concatenation is done, e.g. `"{{ 'javascript:foo' }}"` and `"javascript:{{safeType}}"` will be sanitized. This commit also introduces a new SCE context called `SRC`, which represents a URL being used as a source for an image, video, audio, etc. The hierarchy is setup so that the `URL` context is also a `SRC` context, in the same way that the `RESOURCE_URL` context is also a `URL` (and now also a `SRC`) context. Where we previously sanitized URL attributes inside the compiler, we now only apply the `$sce.URL` or `$sce.SRC` context requirement. * When calling `getTrustedSrc()` a value that is not already a trusted `SRC` will be sanitized using the `imgSrcSanitizationWhitelist` * When calling `getTrustedUrl()` a value that is not already a trusted `URL` will be sanitized using the `aHrefSanitizationWhitelist` This results in behaviour that closely matches the previous sanitization behaviour. BREAKING CHANGES: If you use `attrs.$set` for URL attributes there will be no automated sanitization of the URL value. This is now in line with other contexts. If you are programmatically writing URL values to attributes from untrusted input then you must sanitize it yourself (possibly by calling the private `$$sanitizeUri` service).
- Loading branch information
1 parent
7df2952
commit 36c4de9
Showing
11 changed files
with
542 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.