Skip to content

escapeJs generates invalid JSON #231

@ondrejmirtes

Description

@ondrejmirtes

Cross-posting from: nette/utils#235 (comment)

This code:

str_replace([']]>', '<!'], [']]\x3E', '\x3C!'], $json);

Needs to be:

str_replace([']]>', '<!'], ["]]\x3E", "\x3C!"], $json)

In order to produce valid JSON. Please double-check after me, but when I tried the first version, JSON.parse in the browser complained about an unexpected character because of literal \x3 in there.

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