Skip to content
This repository was archived by the owner on Sep 21, 2025. It is now read-only.

An alternative fix suggestion for legacy apps #5

@dalevink

Description

@dalevink

I have a suggestion, for any existing app that consistently addresses existing XSS vulnerabilities (pre Vue).

For example, you (should?) have an existing "globally" used function, such as:

function htmlEscape($text) {
  return htmlspecialchars(strval($text), ENT_QUOTES, 'UTF-8');
}

Could this be simply altered to include the escaping of Vue template interpolation, eg:

function htmlEscape($text) {
  $text = str_replace("{", "{{ '{' }}", strval($text));
  return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
}

A possible one line fix?

Note: Updated code fix as per suggestion below – thanks to @apreiml

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