Skip to content

Preserve UTF-8 boundaries in advert names#3004

Open
axhoff wants to merge 1 commit into
meshcore-dev:devfrom
axhoff:agent/preserve-utf8-advert-names
Open

Preserve UTF-8 boundaries in advert names#3004
axhoff wants to merge 1 commit into
meshcore-dev:devfrom
axhoff:agent/preserve-utf8-advert-names

Conversation

@axhoff

@axhoff axhoff commented Jul 20, 2026

Copy link
Copy Markdown

Summary

  • truncate advertised node names only at valid UTF-8 code-point boundaries
  • reject malformed, overlong, surrogate, truncated, and out-of-range UTF-8 tails at the final encoder
  • correct the documented advert name capacities to 23 bytes with location and 31 bytes without location
  • add regression coverage for the reported emoji/flag boundary and malformed sequences

Root cause

AdvertDataBuilder::encodeTo() copied names until the raw byte budget was exhausted. Location data leaves 23 bytes for the name, so a 24-byte name could be cut inside a multi-byte code point and emitted as invalid UTF-8.

Scope

The defensive check is at the final encoder, so it protects names saved by older firmware as well as current input paths. The packet layout and byte budgets are unchanged; only the valid prefix that fits is emitted.

Validation

  • git diff --check
  • pio test -e native — 17/17 tests passed
  • pio run -e Heltec_v3_repeater
  • rigorous Fable adversarial review: approved with no actionable findings

Fixes #2613

@axhoff
axhoff marked this pull request as ready for review July 20, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant