Skip to content

Generates incorrect JSON string for U+2028/U+2029 #214

@matthewbjones

Description

@matthewbjones

When the Ruby string contains a Unicode Line Separator character (http://www.fileformat.info/info/unicode/char/2028/index.htm), this library incorrectly generates the final JSON, which causes SyntaxError: Unexpected token ILLEGAL (in Chrome) and Unexpected EOF in Safari, etc.

"Home by Edward Sharpe & the Magnetic Zeros\u2028".to_json
# "\"Home by Edward Sharpe \\u0026 the Magnetic Zeros\u2028\""

should be

# "\"Home by Edward Sharpe \\u0026 the Magnetic Zeros\\u2028\""

As far as I can tell, the JSON spec and browsers treat U+2028/2029 as valid line separator characters, which are not allowed to occur within strings.

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