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 authored and hsbt committed Sep 29, 2020
1 parent c5635fa commit 076ac63
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/webrick/httprequest.rb
Expand Up @@ -226,9 +226,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 @@ -503,7 +503,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 076ac63

Please sign in to comment.