-
-
Notifications
You must be signed in to change notification settings - Fork 407
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
trustedHtml
and trusted-html
#443
base: master
Are you sure you want to change the base?
Conversation
I love this idea 👍. Also, what if |
Whitelisting a subset of HTML is a surprisingly hard problem, see this list of XSS attack vectors for an example of the kinds of thing that you have to deal with. I'd think that responsibility would be better served by an external sanitisation library. |
1d18ceb
to
570fa17
Compare
trustedHtml
and trusted-html
trustedHtml
and trusted-html
570fa17
to
311fa08
Compare
311fa08
to
53a7888
Compare
Thanks @GavinJoyce - this LGTM overall 👍 I definitely prefer I am not as sure about deprecating |
Thanks @dgeb, I've added the following unresolved question to the bottom of the RFC:
To my mind, the fact that I'm interested in what the consensus on deprecating |
It seems unusual for a function to be named after its argument, so I think it's still pretty likely that someone would read this function as something which does the job of sanitization. i.e. "I give this function HTML and it gives me 'trusted' HTML, which must be safe.". I think the best thing to do here would be to have the function name contain a scary warning sign. e.g. |
What about |
I may have more substantial thoughts about the other aspects, but since a big part of this is that there is not one type of "safe" string, I think we should answer these questions:
If you agree with me, I think this calls for a slightly more generic solution, like If we go down this rabbit hole, there is more to unpack/design here – like whether 1 & 2 are really the same thing, and if But bottomline is, I don't think doing nothing is really an option here, allowing |
This resonates with me too and is my one concern about
{{bypass-sanitization myString}} is great for communicating bypassing the escaping provided by myTrustedHtmlString: computed('myString', function() {
return bypassSanitization(this.myString);
} |
Agreed @paddyobrien, I think
While these names will indeed be scary warnings, I think they suffer from similar issues to
@topaxi, I'll add that to the list of alternative names too. I don't think Ember is doing any sanitization so that name might not exactly fit. |
@chancancode interesting. When creating this RFC I was assuming that I hadn't considered your second case nor a new third case which is when used as an element helper (
<div>{{trust this.someTrustedHtml}}</div>
<div style={{trust this.someTrustedStyle}}></div>
<div style="font-size: 2em; {{trust this.someTrustedStyle}}"></div>
If there is uncertainty around naming, perhaps this RFC should stay in draft form until this has been resolved? We could continue to work on the draft, just leave the exact naming until after the other RFC has merged (unless, of course, we agree on a name that is unaffected by other RFCs).
I wonder how useful parsing CSS style at build time would be? Most of the uses of dynamic style string that I've seen in Intercom have included run-time dynamic values. If the style is static at build time, shouldn't it be defined in CSS or in a Possibly beyond the scope of this RFC, but it's probably useful to chat about the likely future direction of this warning. Hopefully we can do better over time:
|
I can only add my limited use cases to this discussion. I mostly find myself using safeString for 2 things:
This default 'no-inline-styles' rule for templates / says that doing those things isn't OK. But I'm not really sure how I would go about those tasks otherwise. https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/no-inline-styles.md
I guess I don't really understand how any of my use-cases could be dangerous... So, I'm naive in that regard - but I'm just putting in a vote for something - not so short that scares everyone away - like |
I tested a bunch of uses of 1.
|
@sheriffderek thanks for providing that example, I think it's a pretty common use case to want to quickly construct a dynamic string of css style from dynamic values that you already trust. I think we have an opportunity to improve developer ergonomics starting with this RFC, but likely continuing with an addon which helps construct trusted dynamic css strings safely - perhaps one already exists? We use an internal
|
Very good proposal! 💯 I think it would make sense to try to deprecate As others have mentioned, I think making it easy to lint against |
It seems that there's been a lot of healthy discussion around this RFC so I'm going to try to get it moving again. |
Rendered