Skip to content

Fix Unicode string decoding in the dependency-free JSON parser #351

Closed

Description

@LunaStev

Problem

utils/src/json.rs parses JSON strings byte by byte. Raw non-ASCII UTF-8 bytes are currently pushed as independent characters, and valid \uXXXX escapes are rejected.

This parser is used for Wave metadata such as the standard-library manifest, so valid JSON strings must round-trip without corruption.

Scope

  • Preserve raw UTF-8 text in JSON strings.
  • Decode \uXXXX escapes.
  • Combine valid UTF-16 surrogate pairs for code points outside the BMP.
  • Reject malformed hexadecimal escapes and lone surrogates.
  • Preserve the existing handling of quotes, slashes, control escapes, and unterminated strings.

Tests

Add unit tests in the utils crate for:

  • Raw Korean and emoji text.
  • BMP Unicode escapes.
  • A surrogate-pair escape.
  • Invalid hex digits.
  • Lone high and low surrogates.
  • Parser/writer round trips.

Completion criteria

  • Valid Unicode JSON strings parse without corruption.
  • Invalid Unicode escapes return an error rather than panicking.
  • cargo test --locked --all-targets --jobs 2 passes.
  • No full serialization dependency is added.

Activity

  1. added
    bug
    good first issue
    on Aug 25, 2026
  2. self-assigned this
    on Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

buggood first issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions