You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
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).
0 commit comments