From b110cfabe8f1ab5e9a3c242575e47b9817efe5ad Mon Sep 17 00:00:00 2001 From: sneak Date: Thu, 19 Nov 2026 18:05:20 +0000 Subject: [PATCH] config: test the header-name check on every single-byte name TestHeaderNameCheckTakesTheRFC9110Characters passed string(char) for a byte, which for 0x80 to 0xff is the two-byte UTF-8 of U+0080 to U+00FF. Half of the names it called single-byte were not checked. It now builds each name from the byte itself. Model: opus-5-5 --- internal/config/waf_test.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/config/waf_test.go b/internal/config/waf_test.go index 6360234..209da16 100644 --- a/internal/config/waf_test.go +++ b/internal/config/waf_test.go @@ -883,8 +883,11 @@ func TestHeaderNameCheckTakesTheRFC9110Characters(t *testing.T) { want := 'a' <= char && char <= 'z' || 'A' <= char && char <= 'Z' || '0' <= char && char <= '9' || strings.IndexByte(marks, char) >= 0 - if got := httpguts.ValidHeaderFieldName(string(char)); got != want { - t.Errorf("the name %q is taken: %t, want %t", char, got, want) + // string(char) would be the UTF-8 of U+0080 to U+00FF, two bytes, + // for a byte above 0x7f. + name := string([]byte{char}) + if got := httpguts.ValidHeaderFieldName(name); got != want { + t.Errorf("the name %q is taken: %t, want %t", name, got, want) } } }