summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Evans <[email protected]>2019-08-06 15:48:18 -0700
committerHiroshi SHIBATA <[email protected]>2019-10-24 19:47:10 +0900
commit37c266aa57fc2c6798a7b6002867643ef0424fa1 (patch)
tree99cd85e253bc58018e76369c86693f1a65c29265
parent84ed4c3d59a3317c6aff017e88f0ea897dbf8410 (diff)
[ruby/webrick] 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. https://github.com/ruby/webrick/commit/8b96088a86
-rw-r--r--lib/webrick/httputils.rb5
-rw-r--r--test/webrick/test_httprequest.rb2
2 files changed, 2 insertions, 5 deletions
diff --git a/lib/webrick/httputils.rb b/lib/webrick/httputils.rb
index 3a2891900f..76d4bd0dc7 100644
--- a/lib/webrick/httputils.rb
+++ b/lib/webrick/httputils.rb
@@ -162,10 +162,7 @@ module WEBrick
end
}
header.each{|key, values|
- values.each{|value|
- value.strip!
- value.gsub!(/\s+/, " ")
- }
+ values.each(&:strip!)
}
header
end
diff --git a/test/webrick/test_httprequest.rb b/test/webrick/test_httprequest.rb
index 592f857f65..4747e5d4f9 100644
--- a/test/webrick/test_httprequest.rb
+++ b/test/webrick/test_httprequest.rb
@@ -135,7 +135,7 @@ GET /
assert_equal("", req.script_name)
assert_equal("/foo/baz", req.path_info)
assert_equal("9", req['content-length'])
- assert_equal("FOO BAR BAZ", req['user-agent'])
+ assert_equal("FOO BAR BAZ", req['user-agent'])
assert_equal("hogehoge\n", req.body)
end