Skip to content

template: a double quote in a dynamic attribute value is not escaped #781

Open

Description

@lionelhorn

A " in a dynamic attribute value is written as is, so user input can close the attribute and add new ones, e.g. an event handler. The template docs say user input is safe in templates.

import { render } from '@deepkit/template';
import { Injector } from '@deepkit/injector';

const userInput = 'x" onmouseover="alert(document.cookie)';

console.log(await render(Injector.from([]), <input value={userInput} />));
// actual: <input value="x" onmouseover="alert(document.cookie)"/>, should be: <input value="x&quot; onmouseover=&quot;alert(document.cookie)"/>

The same happens with a function component's props (<div title={props.name}>).

Master 0bb9fba, Node 26.13.0.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions