Skip to content

user-typed PUA codepoints collide with the marker registry: ANSI-C E401 is silently swallowed (data loss); E301/E314 miscount as length 2 #735

Closed

Description

@caomengxuan666

Summary

A user who types a codepoint that the marker registry also uses has their data silently destroyed or miscounted. This is the concrete payload behind #728: markers.rs carries a user_reachable field whose documented contract is "the entry point producing transport text MUST re-encode that byte (raw-byte marker pair), or the marker silently corrupts data" — and nothing reads that field, so the contract is not enforced anywhere.

Bytes below were captured independently of niu's own od (the probe writes to a file; the bytes are dumped with python from outside), because od on the niu side is itself in the code under test.

Repro

x1=$'\uE301'; printf 'E301 len=%s\n' "${#x1}"
x2=$'\uE401'; printf 'E401 len=%s\n' "${#x2}"
x3=$'\uE314'; printf 'E314 len=%s\n' "${#x3}"
printf '%s' "$x1" > f5a.bin
printf '%s' "$x2" > f5b.bin
codepoint GNU ${#x} niu ${#x} GNU bytes niu bytes
U+E301 1 2 ee 8c 81 ee 8c 81 (identical)
U+E401 1 0 ee 90 81 (empty)
U+E314 1 2 not dumped not dumped

So two distinct defects:

  1. $'\uE401' is swallowed entirely. The value is empty, silently, with rc=0 and no diagnostic. U+E401 is a registered marker (ANSI_C_IFS_GUARD), and a user typing that codepoint through ordinary ANSI-C quoting gets nothing back.
  2. ${#x} is wrong for PUA codepoints (E301, E314 → 2 instead of 1) even when the stored bytes are byte-identical to GNU. Whatever the length is counting, it is not the string.

Why I would treat (1) as data loss rather than an edge case

Environment / method

Niubash 1.4.0 (rubash git e785c3c8f610), Windows 10 x64 (build 19045); GNU bash 5.3.0 via WSL; LF script file; stdout and stderr captured to separate files; byte comparisons by python rather than the in-tree od.

Activity

  1. added
    bug
    P1-high
    area:carrier
    family:M2
    on Oct 17, 2026
  2. added 2 commits that reference this issue on Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1-higharea:carrierbugfamily:M2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions