This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ng-bind-html): watch string value instead of wrapper
Ref: #4045 I have this sinking feeling that support this use case sort of encourages binding to function that blindly trust some html. For now, I'm fixing the issue while I think about the use cases some more. In the case of a function that performs any non-trivial work before wrapping the value (e.g. the showdown filter in issue #3980, or the binding to a simply wrapper function in issue #3932 if it did anything meaty), this fix makes it "work" - but performance is going to suck - you should bind to some other thing on scope that watches the actual source and adjusts itself when that changes (e.g. the showdown filter.) For the case of the wrapper in #3932, if one isn't performing sanitization or some such thing - then you the developer has insight into why that value is safe in that particular context - and it should be available simply by name and not as a result of a function taking any arbitrary input to make auditing of security a little saner. Closes #3932, #3980
- Loading branch information
e2068ad
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.
Should we do a similar thing to
ng-include
's$sce.parseAsResourceUrl
e2068ad
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.
Not needed for the current version (1.2 milestone.)
The HTML path is different because $sce.getTrustedHtml(value) in Angular core will sanitize the HTML to make it trusted if it wasn't a wrapped/blessed value. Sanitizing is expensive which is why I implemented an optimization in commit 068d861. I'll do this for ng-include to support an alternate
$sce
service not from Angular core that has an expensive $sce.getTrustedResourceUrl implementation. Since it's not a pressing or upcoming problem, I'd rather think about the general approach a bit more before pushing on this pattern.