Skip to content

Escape html, when values are not stream like #7

@lorenzofox3

Description

@lorenzofox3

if I take the simple example:

function MyComponent({foo, title, baz, qux, bool}) {
  return html`
    <h1>${title}</h1>
    <div>${foo}</div>
    <div>${baz} ${qux}</div>
    <div>${bool}</div>
  `;
}

I have noticed that if I set foo (or whatever) as an html string like <script>window.alert('pwned')</script> the script is executed.

It would be nice if the templating library could escape this sort of value so I don't need to do it ahead (especially on environment like a nodejs server), don't you think ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions