Skip to content

Warn about unescaped output in attributes #87

@marcoroth

Description

@marcoroth

For a template like:

<div data-config="<%== @config.to_json %>"></div>

This will render as the following in Erubi via ActionView:

<div data-config="{"key":"value"}"></div>

which is not valid HTML and breaks the rendered markup.

Prior to ReActionView 0.3.0, Herb in ReActionView rendered the above template as:

<div data-config="{&quot;key&quot;:&quot;value&quot;}"></div>

With ReActionView 0.3.0 it will now produce invalid markup to match Erubi and to fix marcoroth/herb#1419, but I think we can do better and improve this behavior.

I think we should warn about this, or even disallow it. We could also make it a runtime exception in development by checking the value for characters that need to be escaped in that context.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions