lundi 29 juin 2015

Ember: bind-attr title attribute does not decode properly

My model returns encoded values from the server. The model contains "enc_res_name" which is HTMLEncoded to display inside an element and "encattr_res_name" which is Attribute Encoded to set as attributes to an element.

The issue I am facing is the HTMLEncoded value displays properly within the element. But the title attribute which is set using "bind-attr" does not rendered properly. The Encoded value is displayed as such in the title.

Template:

<ul>
    {{#each item in model}}
        <li>
            <a {{bind-attr title=item.encattr_res_name}}>     
                {{{item.enc_res_name}}}
            </a>
        </li>
    {{/each}}
</ul>

Route:

App.IndexRoute = Ember.Route.extend({
    model: function() {
        return [{'enc_res_name':'&lt;div onmouseover&#x3d;&quot;alert&#x28;document.cookie&#x29;&#x3b;&quot;&gt;haii&lt;&#x2f;div&gt;','encattr_res_name':'&lt;div&#x20;onmouseover&#x3d;&quot;alert&#x28;document.cookie&#x29;&#x3b;&quot;&gt;haii&lt;&#x2f;div&gt;'}];
    } 
});

One solution to set the encoded values to title is use triple curly braces and unbound. But there is an option to rename the value where I need to update the title attribute also.

So I am not sure how to set the title attribute to render the encoded values as human readable.

JSBin Link




Aucun commentaire:

Enregistrer un commentaire