I have a computed property called barWidth that returns a safe string.
return new Ember.Handlebars.SafeString('width:'+progress+'%');
It’s bound to a style of an HTML element in handlebars.
<div class="progress" style="{{barWidth}}">
It all works fine, but I have this warning popping up in my console.
“WARNING: Binding style attributes may introduce cross-site scripting vulnerabilities; please ensure that values being bound are properly escaped. For more information, including how to disable this warning, see Ember.js - Deprecations”
According to the given URL…
Once you have verified that the content being displayed is trusted and properly escaped, you can disable the warning by making the content a SafeString.
The reason the initial version still triggers the warning is that quoting an attribute automatically calls concat on the parameters (even though in this case there is only one). We can likely make the internal HTMLBars concat utility smart enough to return the first param if there is only one (as in this example).
Dropping the quotes worked, Ember no longer throws a warning. I now see that the example in the deprecation guide also has no quotes. I overlooked it before. Thanks @rwjblue!
make a CP that does the concatenating and return a SafeString
make a helper that converts a string into a safe string (Ember already has an internal -html-safe helper that I think we should make public in some fashion) and use that along with concat helper in the template.