ts_control_serde: handle unicode escapes in Resolver - #418
Open
dylan-tailscale wants to merge 1 commit into
Open
dylan-tailscale wants to merge 1 commit into
dylan-tailscale wants to merge 1 commit into
Conversation
dylan-tailscale
requested review from
danderson,
npry and
nrc
as code owners
September 17, 2026 16:45
Updates ResolverAddr to use alloc::string::String instead of &'a str in its variants, allowing DoH/DoT/WireGuard DNS resolver addresses to contain Unicode escapes without panicking. Adds a fake NextDNS address with escaped ampersands to map_response.json so test_map_response_parse can confirm the fix. The control plane escapes ampersands in JSON that it sends as "\u0026", which affects NextDNS users with per-device configuration profiles on their tailnet, as their DoH URLs contain ampersands. serde_json can't deserialize this in-place, leading to "expected a borrowed string" panics that kill the control runner. Moving to alloc::string::String allows the field to be mutated during deserialization. I originally went for Cow<'a, str> to avoid the unconditional allocation, but apparently a Cow becomes an unconditional allocation on deserialization, so we gain nothing over an alloc::string::String. Signed-off-by: Dylan Bargatze <dylan@tailscale.com>
dylan-tailscale
force-pushed
the
dylan/dns-escaping
branch
from
September 17, 2026 20:53
fc6cd29 to
c06c0a5
Compare
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.
Updates
ResolverAddrto usealloc::string::Stringinstead of&'a strin its variants, allowing DoH/DoT/WireGuard DNS resolver addresses to contain Unicode escapes without panicking. Adds a fake NextDNS address with escaped ampersands tomap_response.jsonso test_map_response_parse to confirm the fix.The control plane escapes ampersands in JSON that it sends as
\u0026, which affects NextDNS users with per-device configuration profiles on their tailnet, as their DoH URLs contain ampersands.serde_jsoncan't deserialize this without mutating it, leading to "expected a borrowed string" panics that kill the control runner. Moving toalloc::string::Stringletsserde_jsonmutate aResolverAddr's JSON representation if necessary to deserialize it.This originally used
Cow<'a, &str>, but @npry reminded me thatCow<'a, &str>unconditionally allocates on deserialization anyway, so we might as well go withalloc::string::String. To avoid unnecessary allocation, we'll need to come up with an approach/custom types to allocate only when necessary to decode, since we'll need this in way more fields than just DNS-related ones. Putting this PR up to fix the issue while we cook up a different solution; opened #420 to track developing a better approach.Closes #400.