-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
{{{triples}}} #35
Comments
I think sanitation is largely out of scope here. I'd say allow an optional hook to modify the resulting DOM before dropping it onto the page. If you wanted to make the dev's life a bit simpler, perhaps that hook could be for a visitor function called to filter each node down the resultant DOM tree. |
👍 yeah, reflecting on it a bit I think you're right |
I think sanitization should be the default. It's more often when you need sanitized output than not. |
That definitely hasn't been my experience. The only time you need sanitisation is if you're rendering user input – every time I've used triples it's been to render e.g. a chunk of markdown that I wrote. Also, there are different forms/levels of sanitisation, and you penalise the majority of users if you include all the sanitisation code for everyone who uses triples. |
@Rich-Harris I don't really know how write apps, maybe you always work with people who don't make mistakes, but from my experience people always do and keep forgetting to use the syntax with sanitization. So even if that's only for user's input, it totally makes sense to have sanitization by default. I don't mean triples here actually, I mean default interpolation syntax should sanitize and have a syntax to explicitly bypass it. P.S. "should" in an ideal template engine (or whatever with templates) for me. Not that I'm telling to you what you should do or not :-) |
@NekR the regular interpolators only create text nodes, so there's really nothing to sanitize there. If you want to drop html into the template from a string, you would have to use a triple. |
@evs-chris I see. That makes sense and that's exactly what I meant. Sorry for misunderstanding. |
Makes me think maybe browsers should be responsible for that – maybe a new API, e.g. as well as |
@Rich-Harris Is |
IE has |
@PaulBGD textContent is what regular |
The way I implemented it in #124 btw is without sanitization. I think its the responsibility of the template author to do that, and it would be as simple as definiting a helper and calling |
We'll eventually need some way to inject arbitrary (sanitized? or is that the dev's responsibility?) HTML
The text was updated successfully, but these errors were encountered: