Repository navigation
fix: keep escaped dots inside first label in name_change/hostname_change (fix #546) - #547
Merged
keepsimple1 merged 5 commits intoNov 19, 2026
Merged
Conversation
…nge (fix keepsimple1#546) Both rename helpers took the first label via split('.'), which also splits on dots escaped as \. per RFC 6763 section 4.3. A probe conflict on an instance like L\.A\.R\.A Hub._lara._tcp.local. produced L\ (2).A\.R\.A Hub with an extra label instead of L\.A\.R\.A Hub (2)._lara._tcp.local., and the result could not round-trip through write_name, leaving the renamed instance unanswerable. split_first_label now scans for the first unescaped dot (a backslash escapes the next character, so \\. still terminates the label) and the suffix is appended inside the real first label. AI assistance: prepared with an AI coding agent; new escaped-dot cases pass in test_name_change and test_hostname_change.
Rephrase the doc comment so a backslash-escaped token does not start a continuation line, which clippy parses as an unindented list item (CI: Lint and Documentation, windows-2025 clippy step).
Sealdot
force-pushed
the
fix-escaped-dot-first-label
branch
from
November 11, 2026 04:00
8a8cea7 to
e621597
Compare
The doc block for name_change was left above split_first_label, which also triggered clippy::doc_lazy_continuation after the list items.
Sealdot
marked this pull request as ready for review
November 14, 2026 00:35
Contributor
Author
|
CI is green and the change is complete on my side — marking ready for review. |
keepsimple1
reviewed
Nov 15, 2026
This was referenced Nov 15, 2026
keepsimple1
reviewed
Nov 15, 2026
keepsimple1
reviewed
Nov 15, 2026
keepsimple1
left a comment
Owner
There was a problem hiding this comment.
Thanks for your PR! Overall looks good. Comments inline.
Add EscapedLabels, an iterator over the escaped label slices of a name, so the RFC 6763 section 4.3 boundary rule lives in exactly one place. parse_escaped_name now unescapes each yielded slice and drops the empty ones; split_first_label takes the first slice and keeps the escaped remainder. Boundary and unescape behavior are unchanged, including empty labels and unrecognized escapes. Also fix the rename fallback for a name whose first label is empty: `._lara._tcp.local.` now keeps its suffix inside that label, restoring the pre-PR result ` (2)._lara._tcp.local.` instead of `._lara._tcp.local. (2)`, and document the return value of split_first_label. Addresses review feedback; implements the shared splitter suggested in keepsimple1#550. AI assistance: Cognition Devin CLI agent (SWE-2 High).
Sealdot
added a commit
to Sealdot/mdns-sd
that referenced
this pull request
Nov 19, 2026
When a probe conflict triggers name_change/hostname_change, the appended ` (n)`/`-n` suffix can push the first label past MAX_LABEL_BYTES, after which write_name rejects every packet and the service silently vanishes. Shorten the base so the label with the new suffix still fits, like mDNSResponder: measure wire bytes via escape-aware helpers in dns_parser.rs (\. and \\ count as one byte, never cut inside a pair or a UTF-8 char), trim a trailing space/`-`, and recompute on every rename as ` (9)` -> ` (10)` grows the suffix. register_service now rejects an instance label over 63 wire bytes up front instead of failing silently on the network. Fixes keepsimple1#549. Rebased onto main @ ea547cd (keepsimple1#547): the truncation is ported onto EscapedLabels/split_first_label so escaped first labels keep the suffix inside the label. AI assistance: Cognition Devin CLI agent (SWE-2 High).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
name_changeandhostname_changetake the first label withoriginal.split('.'), which also splits on a dot escaped as\.(RFC 6763 §4.3). For a conflicted instance likeL\.A\.R\.A Hub._lara._tcp.local., the rename producedL\ (2).A\.R\.A Hub._lara._tcp.local.— an extra label, a different instance — and the result could not round-trip throughwrite_name, so queries for the renamed instance still went unanswered.hostname_changehad the same bug:my\.host.local.→my\-2.host.local.instead ofmy\.host-2.local..Fix
New
split_first_labelscans for the first unescaped dot — a backslash escapes the following character, so\\.still terminates the label — and the(n)/-nsuffix is applied inside the real first label. The rest of the name is kept verbatim instead of re-joining on dots.Tests
New escaped-dot cases in
test_name_change/test_hostname_change(exactly the examples in the issue, plus the\\.backslash-escape edge):cargo test --lib _change→ 3/3 pass on Rust 1.97.AI assistance: the change and tests were prepared with an AI coding agent.
Update (commit 9920041): shared label splitter, addressing review feedback + #550
Following the suggestion in #550, the RFC 6763 §4.3 boundary rule now lives in exactly one place: a new
EscapedLabelsiterator indns_parser.rsyields each escaped label slice (empty ones included).parse_escaped_nameunescapes each slice and drops the empties;split_first_labeltakes the first slice and keeps the escaped remainder. Boundary and unescape behavior are unchanged.Review feedback addressed:
._lara._tcp.local.) now gets the rename suffix inside that label, restoring the pre-PR result(2)._lara._tcp.local.— the fallback that appended(2)to the end of the whole name is removed.split_first_labelnow documents its return value.New tests cover every case listed in #550 (
a\.b,a\\.b,a\x.b,a\\\.b, trailing\, leading.,..) asserting both the slices and theparse_escaped_nameoutput, plus the empty-first-label rename cases.cargo test --lib94/94, doc 4/4, clippy--all-targetsclean (cargo 1.97.1, macOS arm64).