Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

feat(ng_bind_html): Configurable sanitizer via injectable NodeValidator. #490

Closed
wants to merge 5 commits into from
Closed

feat(ng_bind_html): Configurable sanitizer via injectable NodeValidator. #490

wants to merge 5 commits into from

Conversation

bgourlie
Copy link
Contributor

@bgourlie bgourlie commented Feb 1, 2014

No description provided.

@chirayuk
Copy link
Contributor

chirayuk commented Feb 4, 2014

I agree that ng_bind_html should use a configurable NodeValidator.  However, putting it as the default NodeValidator for the entire app (i.e. not just for use by ng_bind_html) implies that the only possible use for a NodeValidator is to sanitize for ng_bind_html.  In AngularJS, we use the $sanitize service to sanitize the html.  We don't have such a service here. Adding such a service would mean that you could replace the $sanitize service with one of your choice giving you the same functionality provided by this PR but without installing it as a dom.NodeValidator (which doesn't convey the intent/purpose.)

@chirayuk chirayuk closed this Feb 4, 2014
@bgourlie
Copy link
Contributor Author

bgourlie commented Feb 4, 2014

I appreciate the feedback Chirayu! I'll look into implementing something similar to angularjs.

@bgourlie
Copy link
Contributor Author

bgourlie commented Feb 4, 2014

@chirayuk So I looked into this and I don't think it's (reasonably) possible to implement a $sanitize service similar to angularjs. In dart, Element.innerHtml and Element.setInnerHtml are always sanitized and the only way to override default sanitization is to pass a custom dom.NodeValidator to it. In order for this to work similarly to angularjs, we'd have to create a dom.NodeValidator that does no sanitization, and then reimplement sanitization entirely, which would be far from ideal.

In order for this to work nicely, the $sanitize service would hold the reference to the dom.NodeValidator and would be responsible for setting the innerHtml of the element. Any thoughts on how to do this or alternative ideas?

@mhevery
Copy link
Contributor

mhevery commented Feb 6, 2014

Resurrecting, as I think it is reasonable approach.

@mhevery mhevery reopened this Feb 6, 2014
mhevery pushed a commit to mhevery/angular.dart that referenced this pull request Feb 6, 2014
@mhevery mhevery closed this in 47ab48a Feb 6, 2014
@bgourlie bgourlie deleted the injectable-nodevalidator branch February 6, 2014 16:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.

3 participants