Skip to content

Commit af2efdc

Browse files
mamehsbt
authored andcommitted
Make it more strict to interpret some headers
Some regexps were too tolerant.
1 parent d7fc6f1 commit af2efdc

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
@@ -226,9 +226,9 @@ def parse(socket=nil)
226226
raise HTTPStatus::BadRequest, "bad URI `#{@unparsed_uri}'."
227227
end
228228

229-
if /close/io =~ self["connection"]
229+
if /\Aclose\z/io =~ self["connection"]
230230
@keep_alive = false
231-
elsif /keep-alive/io =~ self["connection"]
231+
elsif /\Akeep-alive\z/io =~ self["connection"]
232232
@keep_alive = true
233233
elsif @http_version < "1.1"
234234
@keep_alive = false
@@ -503,7 +503,7 @@ def read_body(socket, block)
503503
return unless socket
504504
if tc = self['transfer-encoding']
505505
case tc
506-
when /chunked/io then read_chunked(socket, block)
506+
when /\Achunked\z/io then read_chunked(socket, block)
507507
else raise HTTPStatus::NotImplemented, "Transfer-Encoding: #{tc}."
508508
end
509509
elsif self['content-length'] || @remaining_size

0 commit comments

Comments
 (0)