Skip to content

id(world): sanitize_display_name takes its 48 characters before trimming — leading spaces spend the budget, so a padded name is truncated to its first letters or refused as empty #3709

Closed

Description

@dezren39

id(world): sanitize_display_name takes its 48 characters before trimming — leading spaces spend the budget, so a padded name is truncated to its first letters or refused as empty

Problem

sanitize_display_name (pkgs/id/src/world/util.rs:69-76) builds a participant's display name in this order: filter control characters → take(48) → collect → trim(). The 48-character budget is measured before the trim, so leading whitespace that the trim is about to delete consumes the budget first:

  • A name of 48 spaces followed by Bob sanitizes to "" — and the join path (pkgs/id/src/world/core.rs:877-880) then refuses the join with "participant display name must not be empty", even though the name has real content.
  • 47 spaces + Bob sanitizes to "B"; 46 spaces + Bob to "Bo" — the participant joins under a silently truncated name.
  • A single leading space in front of an exactly-48-character name drops the name's last character (47 survive).

The ordering is also internally inconsistent: control characters (including tab) are filtered before take(48), so 50 control characters or 60 tabs in front of Bob cost no budget at all and Bob survives whole — only whitespace that survives the filter but is later trimmed is charged against the budget.

Evidence (verified this run on main a9318ea8)

  • pkgs/id/src/world/util.rs:69-76: .filter(|ch| !ch.is_control()).take(48).collect::<String>().trim() — take precedes trim.
  • Only production caller: pkgs/id/src/world/core.rs:877 (let display_name = sanitize_display_name(display_name);), immediately followed at :878-881 by the non-empty refusal that the padded-name case trips.
  • Laptop probe ~/git/fleet/probe-2026-11-01-laneA-dispname/ (verbatim copy of the function; laptop clone at the same HEAD a9318ea8, world/util.rs sha256 6c6cab0187e41519eb4fd8b55633b905f33006073e27f42743a024400d2bfb39 on both clones; output read back from probe-run.log in a second call):
input output
Bob (control) "Bob"
Bob (control) "Bob"
48 spaces + Bob "" (empty — join refused)
47 spaces + Bob "B"
46 spaces + Bob "Bo"
1 space + 48-char name 47 chars (last char dropped)
50 × U+0007 + Bob (control) "Bob"
60 tabs + Bob (control) "Bob"

Why it matters

Display names arrive from join/delegate callers that do not pre-trim (the sanitizer is the single choke point, and its own contract is "filter, bound, trim"). A user whose client pads a name — or whose name legitimately starts with spaces that will be trimmed anyway — is either refused a join for an "empty" name that is not empty, or appears in the world under a one- or two-letter truncation of their name with no error anywhere. The fix is a reorder, but the current order also means the documented 48-character limit is not the limit on the name that is actually stored: it is a limit on the untrimmed string.

Distinct from #2112 (same function, different defect: category-Cf characters pass the filter — its acceptance criteria cover Cf removal and Cf-only names, not the take/trim order or whitespace padding). No other open or closed issue covers this: creator dedupe 2026-11-01 searched open+closed for the sanitizer, the 48-char budget, and trim/take ordering; the only hit was #2112.

Acceptance criteria

  • sanitize_display_name applies the 48-character budget to the trimmed name: leading/trailing whitespace is removed before (or otherwise not charged against) the budget — e.g. trim first, then filter, then take, with a final trim if the filter can expose new edges.
  • 48 spaces + Bob sanitizes to "Bob" (and the join at world/core.rs accepts it); 47/46 spaces + Bob also yield "Bob", not "B"/"Bo".
  • A leading space + an exactly-48-character name yields all 48 characters; a name whose trimmed form exceeds 48 characters is still truncated to 48.
  • Existing behaviour is preserved: control characters are stripped and do not consume the budget, an all-whitespace name still sanitizes to empty (join refusal still fires for genuinely empty names), and interior whitespace is untouched.
  • Unit tests cover the padded cases above (48/47/46 spaces, space + 48-char name, controls control case); existing world tests pass.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    source/creatorFiled by the new-issue-creator job
    priority/lowNice to have; do when convenient
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    on Nov 1, 2026
  2. developing-today commented on Nov 1, 2026

    @developing-today
    Contributor
  3. dezren39 commented on Nov 1, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator job (new-issue-creator-code-a)
    • Session / ID: cron job new-issue-creator-code-a, run 2026-11-01 07:35 CST
    • Found via: filed this run
    • Task: Fix sanitize_display_name (pkgs/id/src/world/util.rs:69-76) so the 48-character budget is measured on the trimmed name — today take(48) runs before trim(), so leading spaces spend the budget: 48 spaces + "Bob" sanitizes to "" and the join refuses it as empty, 47/46 spaces + "Bob" join as "B"/"Bo".
    • Expectation: effort/s — done when the acceptance criteria on this issue pass, including unit tests for the padded cases (48/47/46 spaces, space + 48-char name) and the control cases (controls stripped free of budget, all-whitespace still empty).
    • Links: evidence in the issue body; laptop probe at ~/git/fleet/probe-2026-11-01-laneA-dispname/ (verbatim copy of the function, util.rs sha256 6c6cab01… at main a9318ea on both clones; probe-run.log read back in a second call: controls "Bob", 48sp→"", 47sp→"B", 46sp→"Bo", 1sp+48-char→47 chars).
  4. added
    queue/claimedQueue worker lifecycle state
    and removed on Nov 2, 2026
  5. 32 remaining items

  6. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed
    queue/claimedQueue worker lifecycle state
    on Nov 2, 2026
  7. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    agent-note:v1

  8. added
    queue/claimedQueue worker lifecycle state
    and removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Nov 2, 2026
  9. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    agent: repo-worker-code (lane E)
    state: done
    task: 6180
    issue: 3709
    pr: 4308

    PR #4308 MERGED (squash, f854b4d); issue #3709 CLOSED. The earlier Drew-owned park was the shared-account false positive: PR #4308 is the fleet canonical PR (branch queue/6180-3709-trim-display-name, body binds task 6180 / Closes #3709, no hard-stop labels) — judged by branch + body + labels, not authorship. Verification: diff is exactly the trim-before-take(48) reorder plus regression tests for the padded cases; laptop cargo test --lib for pkgs/id: 474 passed, 0 failed; fresh Codex round on head 8f0ab9f clean (receipt 2026-11-02T11:24:16Z, no findings). GitHub basic-guard/arm64 checks were still QUEUED at merge (runner backlog) — merged on laptop verification + Codex clean per standing merge authority.

  10. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    agent: repo-worker-code (lane E)
    state: done (evidence correction)
    task: 6180
    issue: 3709
    pr: 4308

    Correction to the test evidence in my closing note for task 6180: the "474 passed" laptop tally was NOT reliable — the authoritative terminal output of that run (delivered late) shows its name filter matched 0 tests in the shown binaries. Verified directly, synchronously, on a compiled binary that includes this merge (f854b4d): world::util display_name tests 7 passed, 0 failed, including display_name_trims_before_applying_character_budget (this issue's regression). Note the full lib binary cannot complete locally right now due to the pre-existing cli::tests stack overflow tracked as #4327, which reproduces on binaries built without either of today's id changes. Plus the fresh Codex round on 8f0ab9f was clean. The fix itself stands; only the tally in the earlier note was wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/lowNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions