Skip to content

Co-Work: a name keeps no format characters, from the LAN too - #439

Merged
IPedrax merged 2 commits into
IPedrax:mainfrom
harijsvucens:fix/cowork-names
Nov 13, 2026
Merged

IPedrax merged 2 commits into
IPedrax:mainfrom
harijsvucens:fix/cowork-names

Conversation

@harijsvucens

Copy link
Copy Markdown
Contributor

What and why

A display name was cleaned of control characters only, so it kept every Unicode format character (the Cf
general category): U+202E RIGHT-TO-LEFT OVERRIDE, U+200B ZERO WIDTH SPACE, U+00AD SOFT HYPHEN, U+FEFF ZERO
WIDTH NO-BREAK SPACE, U+2066..U+2069 BIDI ISOLATES and the rest. Those characters mostly draw as nothing yet
change what is drawn around them, so a guest could show Bo<U+202E> (which renders oB), or a name
indistinguishable from another participant's: in the host's people list, in the guests' copy of it, in the
knock dialog and in each other's cursor labels. This is impersonation, not cosmetics.

The same gap was one row wider: the Join list (crates/ui-egui/src/cowork.rs) shows a host it found on the
LAN as "{name} · {project} · {addr}", and discovery::found read those two from a UDP answer nothing
authenticates
, with a length cap only. A U+202E in that name reversed the rest of the row, so the address
the user reads was not the address shown. Both are now cleaned the same way.

Names are filtered of control and format characters by one helper, so there is no second cleaner with a
different rule.

Behaviour

  • host::clean(name, max, fallback) (pub(crate)) filters c.is_control() || is_format(c), trims, cuts to
    max characters and falls back when nothing is left. is_format is an explicit list of the Cf ranges
    (U+2060..U+2064 and U+2066..U+206F listed separately, since U+2065 is unassigned), because std has no
    general-category test and the crate takes no regex dependency.
  • It is the one rule for every place a name is cleaned: the hello (host.rs), a knock's name (host.rs), the
    host's name a guest keeps from the welcome and from a moved handover (live.rs), both copies of the people
    list — the host's (HostEvent::Joined) and the guest's (Joined::take, where live.rs had an inline closure
    with a rule of its own, and no trimming) — and now discovery's name and project.
  • max is an argument rather than MAX_NAME, so discovery keeps its own caps: 40 characters for a host's name,
    200 for a project (a project longer than 40 used to keep its length and now still does). A name that is too
    long, or that is not a string at all, no longer drops the answer from the list: it is cut or falls back to
    "the host" / "a project", which is what the Join row needs. The tag, the port and the version are still
    read strictly, so a datagram that is not an answer is passed over.
  • A name that is letters in another script, accents, hanzi or an emoji is untouched: this removes format
    characters only.

File compatibility

None. No field, no default and nothing written changes, so FORMAT stays as it is and an older build reads
these names exactly as it did. MAX_NAME and the "Guest" fallback are unchanged.

Tests

  • tests::a_name_keeps_no_invisible_format_characters_and_an_honest_one_is_kept
    (crates/cowork/src/tests.rs): Bo + U+202E + U+200B + U+00AD + U+FEFF comes out Bo; U+2066 / U+2069
    around it come out Bo; a name of nothing but them is Guest; U+06DD, U+E0041 and U+1BCA0 (one from the
    Arabic marks, the tags and the shorthand) go too, so a typo in those ranges fails; José, 李 and Ana 🏠
    come back unchanged; a name in a 3-byte-per-character script is cut to MAX_NAME characters, not bytes.
  • tests::a_hello_is_read_strictly_and_its_name_made_safe: the hello's name now carries a U+202E and the test
    asserts the joined name does not contain it — a red assertion on the old code, not only a compile error —
    beside the existing check that no control character survives, the cut and starts_with("Bo").
  • tests::a_guest_finds_a_host_on_the_lan_by_its_code_and_ignores_junk: a forged here answer carrying
    An<U+202E>a / Ho<U+200B>use is listed as Ana / House, and an honest José / Casa 李 beside it
    arrives unchanged. This failed on the previous commit with
    [("An\u{202e}a", "Ho\u{200b}use"), ("José", "Casa 李")] — red before the fix, green after.
  • The crate's suite, 27 tests, passes (cargo test -p bimcraft-cowork), and the gate —
    notes/verify.ps1 -TestFilter a_name_keeps_no_invisible_format_characters — passed: cargo fmt --check,
    cargo i18n check, clippy of bimcraft-cowork, core and the UI (the docs/ edit pulls the last two in), and
    the focused tests. The .pot was not touched: no interface string was added.

Note for a reviewer: no visual coverage — a label's rendering of these characters is not something a unit test
sees; the call sites are the whole of the rule, and is_control in crates/cowork now appears only in error
text (guest.rs, knock.rs, see Not done) and in the tag/version check of discovery.rs.

Not done

  • Homoglyphs are still allowed. Аna with a Cyrillic А is a different string and stays as it is; telling
    people apart by script or by comparing names is a policy, not a filter, and two guests can also still choose
    the same visible name on purpose.
  • A ZWJ emoji sequence is no longer one glyph. U+200D ZERO WIDTH JOINER is Cf and goes with the rest, so
    👩‍💻 arrives as 👩💻 — two emoji. Deliberate: a joiner is also what hides a sequence, and a name is not
    worth an exception.
  • A few Cf characters do show and go anyway: U+0600 ARABIC NUMBER SIGN, U+06DD ARABIC END OF AYAH,
    U+070F SYRIAC ABBREVIATION MARK. A name needs none of them, and the rule is the category, not "invisible".
  • ended reasons are still filtered with is_control only (guest.rs, knock.rs): they are sentences in a
    dialog rather than a name, and the same reordering applies, but changing them is its own decision about error
    text; not this PR.
  • Line and paragraph separators (U+2028, U+2029, category Zl/Zp, not Cf) are not removed; they draw as
    a break rather than as nothing, so they do not hide a name, but a label containing one still looks odd.
  • Validity of what remains (an emoji-only name, a long name in one glyph sequence) is unchanged.

A name was cleaned of control characters only, so U+202E (a right-to-left
override), zero-width spaces and joiners, a soft hyphen, a byte-order mark and
an isolate all survived: "Bo" followed by an override draws as "oB", and a
zero-width space makes one person's name the same pixels as another's, in the
people list and in a knock's dialog.

Names are now cleaned of Unicode's format characters (the Cf category) too, by
one helper, host::clean, which the hello, the knock, the host's name a guest
keeps and both copies of the people list use; the guest's copy had a second
inline rule of its own. Truncation to MAX_NAME still counts characters, and a
name left with nothing is the fallback it was ("Guest", "the host").

Tested by tests::a_name_keeps_no_invisible_format_characters_and_an_honest_one_is_kept:
an override, a zero-width space, a soft hyphen, a BOM and an isolate come out, a
name of nothing but them is "Guest", Jose with an accent, a Chinese character
and an emoji are kept unchanged, and a long name is cut to MAX_NAME characters.
The crate's 27 tests pass, as do the gate's fmt, i18n and clippy.

No FORMAT change: nothing new is written to a file, and an older build reads
these names as it always did.
The Join list read a host's name and project from a UDP answer that nothing
authenticates, with a length cap only, and showed them as "name · project ·
addr": a U+202E in the name reversed the rest of that row, so the address the
user reads was wrong. Both now go through host::clean, which also gains the cap
as an argument so a project of up to 200 characters keeps them instead of being
cut to MAX_NAME; the tag, port and version are still read strictly, so a
datagram that isn't an answer is passed over. A missing name is "the host", a
missing project "a project", rather than the row disappearing.

The tests are red assertions now, not a compile error. The hello test puts a
U+202E in the guest's name and asserts the joined name does not contain it; the
LAN test forges "An␮a · Ho‌use" and "José · Casa 李" and asserts the first is
cleaned and the second kept; the cleaning test gains U+06DD, U+E0041 and
U+1BCA0, one per range a typo in the list would miss.

is_format splits '\u{2060}'..='\u{206F}' into 2060..=2064 and 2066..=206F:
U+2065 is unassigned, and the comment claimed the range was format characters.
The wording follows: clean and docs/areas/cowork.md say "no control or format
characters" rather than "invisible" ones, because U+0600, U+06DD and U+070F are
Cf and do show, and is_format says most are invisible while those few go too.
A name that joins emoji with U+200D is therefore no longer one glyph: that is a
deliberate line, and it is in the PR body's "Not done".

Tested by the gate (fmt, i18n, clippy of cowork, core and the UI, the cleaning
test) and by the crate's 27 tests. No FORMAT change: nothing new is written to a
file, and an older build reads these names as it did.
@github-project-automation github-project-automation Bot moved this to Backlog in BIMCraft Nov 13, 2026
@IPedrax
IPedrax merged commit 66d281a into IPedrax:main Nov 13, 2026
5 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in BIMCraft Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants