Skip to content

Commit 8946bb3

Browse files
committed
Make it more strict to interpret some headers
Some regexps were too tolerant.
1 parent 45d68f9 commit 8946bb3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/webrick/httprequest.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,9 @@ def parse(socket=nil)
227227
raise HTTPStatus::BadRequest, "bad URI `#{@unparsed_uri}'."
228228
end
229229

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

0 commit comments

Comments
 (0)