Skip to content

Bug: Redbean's EncodeJSON escapes too much #1427

@cloudspeech

Description

@cloudspeech

Contact Details

No response

What happened?

Redbean's EncodeJson built-in has documented assumptions about strings: "We assume strings in value contain UTF-8. This serializer currently does not produce UTF-8 output. The output format is right now ASCII."

Forward slashes and equal signs are ASCII and will not be escaped in common JSON serializers. However, Redbean escapes them:

: print(EncodeJson('/'))
"\/"
: print(EncodeJson('='))
"\u003d"

This is unwarranted in line of the JSON spec https://www.json.org/json-en.html.

I expect the Redbean JSON encoder to only escape when the spec demands it.

Version

redbean 3.0.0

What operating system are you seeing the problem on?

Linux

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    medium severityUsed to report medium severity bugs (e.g. Malfunctioning Features but still useable)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions