ruby-changes:58404
From: Jeremy <ko1@a...>
Date: Thu, 24 Oct 2019 19:56:16 +0900 (JST)
Subject: [ruby-changes:58404] 37c266aa57 (master): [ruby/webrick] Remove the squishing of whitespace in header values
https://git.ruby-lang.org/ruby.git/commit/?id=37c266aa57 From 37c266aa57fc2c6798a7b6002867643ef0424fa1 Mon Sep 17 00:00:00 2001 From: Jeremy Evans <code@j...> Date: Tue, 6 Aug 2019 15:48:18 -0700 Subject: [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 diff --git a/lib/webrick/httputils.rb b/lib/webrick/httputils.rb index 3a28919..76d4bd0 100644 --- a/lib/webrick/httputils.rb +++ b/lib/webrick/httputils.rb @@ -162,10 +162,7 @@ module WEBrick https://github.com/ruby/ruby/blob/trunk/lib/webrick/httputils.rb#L162 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 592f857..4747e5d 100644 --- a/test/webrick/test_httprequest.rb +++ b/test/webrick/test_httprequest.rb @@ -135,7 +135,7 @@ GET / https://github.com/ruby/ruby/blob/trunk/test/webrick/test_httprequest.rb#L135 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 -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/