Skip to content

Implement Encode.forJSON() #16

@OpenGG

Description

@OpenGG

The XSS prevention cheat sheet mentioned the anti-pattern, placing json inside js block.

<script>
  var initData = <%= data.to_json %>; // Do NOT do this without encoding the data with one of the techniques listed below.
</script>

This has been a common practice, and is an important part of redux's server rendering. But owasp-java-encoder doesn't has the right encoding function to deal with it.

Is it consider doable and necessary, to implement Encode.forJSON()?

From what I read on the cheat sheet, converting < to \u003c would be good enough.

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