Skip to content

Commit

Permalink
Make it more strict to interpret some headers
Browse files Browse the repository at this point in the history
Some regexps were too tolerant.
  • Loading branch information
mame committed Sep 29, 2020
1 parent 45d68f9 commit 8946bb3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/webrick/httprequest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ def parse(socket=nil)
raise HTTPStatus::BadRequest, "bad URI `#{@unparsed_uri}'."
end

if /close/io =~ self["connection"]
if /\Aclose\z/io =~ self["connection"]
@keep_alive = false
elsif /keep-alive/io =~ self["connection"]
elsif /\Akeep-alive\z/io =~ self["connection"]
@keep_alive = true
elsif @http_version < "1.1"
@keep_alive = false
Expand Down Expand Up @@ -508,7 +508,7 @@ def read_body(socket, block)
return unless socket
if tc = self['transfer-encoding']
case tc
when /chunked/io then read_chunked(socket, block)
when /\Achunked\z/io then read_chunked(socket, block)
else raise HTTPStatus::NotImplemented, "Transfer-Encoding: #{tc}."
end
elsif self['content-length'] || @remaining_size
Expand Down

0 comments on commit 8946bb3

Please sign in to comment.