ipn/ipnlocal: q-encode (RFC 2047) Tailscale serve header values

Updates #11603

RELNOTE=Tailscale serve headers are now RFC 2047 Q-encoded

Change-Id: I1314b65ecf5d39a5a601676346ec2c334fdef042
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2024-04-03 08:48:58 -07:00
committed by Brad Fitzpatrick
parent 262fa8a01e
commit b9611461e5
2 changed files with 37 additions and 2 deletions

View File

@@ -823,3 +823,21 @@ func Test_isGRPCContentType(t *testing.T) {
}
}
}
func TestEncTailscaleHeaderValue(t *testing.T) {
tests := []struct {
in string
want string
}{
{"", ""},
{"Alice Smith", "Alice Smith"},
{"Bad\xffUTF-8", ""},
{"Krūmiņa", "=?utf-8?q?Kr=C5=ABmi=C5=86a?="},
}
for _, tt := range tests {
got := encTailscaleHeaderValue(tt.in)
if got != tt.want {
t.Errorf("encTailscaleHeaderValue(%q) = %q, want %q", tt.in, got, tt.want)
}
}
}