File tree 2 files changed +7
-6
lines changed 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -574,13 +574,10 @@ func canonicalMIMEHeaderKey(a []byte) string {
574
574
// and upper case after each dash.
575
575
// (Host, User-Agent, If-Modified-Since).
576
576
// MIME headers are ASCII only, so no Unicode issues.
577
- if a [i ] == ' ' {
578
- a [i ] = '-'
579
- upper = true
580
- continue
581
- }
582
577
c := a [i ]
583
- if upper && 'a' <= c && c <= 'z' {
578
+ if c == ' ' {
579
+ c = '-'
580
+ } else if upper && 'a' <= c && c <= 'z' {
584
581
c -= toLower
585
582
} else if ! upper && 'A' <= c && c <= 'Z' {
586
583
c += toLower
Original file line number Diff line number Diff line change @@ -25,6 +25,10 @@ var canonicalHeaderKeyTests = []canonicalHeaderKeyTest{
25
25
{"user-agent" , "User-Agent" },
26
26
{"USER-AGENT" , "User-Agent" },
27
27
{"üser-agenT" , "üser-Agent" }, // non-ASCII unchanged
28
+
29
+ // This caused a panic due to mishandling of a space:
30
+ {"C Ontent-Transfer-Encoding" , "C-Ontent-Transfer-Encoding" },
31
+ {"foo bar" , "Foo-Bar" },
28
32
}
29
33
30
34
func TestCanonicalMIMEHeaderKey (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments