You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CanonicalMIMEHeaderKey panics on certain inputs containing spaces.
Reported from a Google user.
e.g. "C Ontent-Transfer-Encoding" will crash.
I'm getting hg codereview SSL errors now (gogo-inflight SSL MITM?) but fix is here:
diff -r 78cebfb89b21 src/pkg/net/textproto/reader.go
--- a/src/pkg/net/textproto/reader.go Fri Nov 01 09:18:35 2013 -0700
+++ b/src/pkg/net/textproto/reader.go Sun Nov 03 13:58:32 2013 -0800
@@ -574,13 +574,10 @@
// and upper case after each dash.
// (Host, User-Agent, If-Modified-Since).
// MIME headers are ASCII only, so no Unicode issues.
- if a[i] == ' ' {
- a[i] = '-'
- upper = true
- continue
- }
c := a[i]
- if upper && 'a' <= c && c <= 'z' {
+ if c == ' ' {
+ c = '-'
+ } else if upper && 'a' <= c && c <= 'z' {
c -= toLower
} else if !upper && 'A' <= c && c <= 'Z' {
c += toLower
diff -r 78cebfb89b21 src/pkg/net/textproto/reader_test.go
--- a/src/pkg/net/textproto/reader_test.go Fri Nov 01 09:18:35 2013 -0700
+++ b/src/pkg/net/textproto/reader_test.go Sun Nov 03 13:58:32 2013 -0800
@@ -25,6 +25,10 @@
{"user-agent", "User-Agent"},
{"USER-AGENT", "User-Agent"},
{"üser-agenT", "üser-Agent"}, // non-ASCII unchanged
+
+ // This caused a panic due to mishandling of a space:
+ {"C Ontent-Transfer-Encoding", "C-Ontent-Transfer-Encoding"},
+ {"foo bar", "Foo-Bar"},
}
func TestCanonicalMIMEHeaderKey(t *testing.T) {
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: