Skip to content

Commit 8b96088

Browse files
committed
Remove the squishing of whitespace in header values
While the stripping of header values is required by RFC 2616 4.2 and RFC 7230 3.2.4, the squishing is not and can break things, such as when one header contains an HMAC of another header. Fixes Ruby Bug 7021.
1 parent 00c281c commit 8b96088

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

lib/webrick/httputils.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,7 @@ def parse_header(raw)
162162
end
163163
}
164164
header.each{|key, values|
165-
values.each{|value|
166-
value.strip!
167-
value.gsub!(/\s+/, " ")
168-
}
165+
values.each(&:strip!)
169166
}
170167
header
171168
end

test/webrick/test_httprequest.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def test_parse_header2()
135135
assert_equal("", req.script_name)
136136
assert_equal("/foo/baz", req.path_info)
137137
assert_equal("9", req['content-length'])
138-
assert_equal("FOO BAR BAZ", req['user-agent'])
138+
assert_equal("FOO BAR BAZ", req['user-agent'])
139139
assert_equal("hogehoge\n", req.body)
140140
end
141141

0 commit comments

Comments
 (0)