Skip to content

Commit

Permalink
Remove unnecessary gsub calls in test_httprequest.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyevans committed Jul 11, 2024
1 parent 426e214 commit e4efb4a
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions test/webrick/test_httprequest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_invalid_content_length_header
HTTP
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
assert_raise(WEBrick::HTTPStatus::BadRequest){
req.parse(StringIO.new(msg.gsub(/^ {8}/, "").gsub("\n", "\r\n")))
req.parse(StringIO.new(msg))
}
end
end
Expand All @@ -102,7 +102,7 @@ def test_bare_lf_request_line
HTTP
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
assert_raise(WEBrick::HTTPStatus::BadRequest){
req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
req.parse(StringIO.new(msg))
}
end

Expand All @@ -114,7 +114,7 @@ def test_bare_lf_header
HTTP
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
assert_raise(WEBrick::HTTPStatus::BadRequest){
req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
req.parse(StringIO.new(msg))
}
end

Expand All @@ -125,7 +125,7 @@ def test_header_vt_ff_whitespace
\r
HTTP
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
req.parse(StringIO.new(msg))
assert_equal("\x0b1\x0c", req["Foo"])

msg = <<~HTTP
Expand All @@ -135,7 +135,7 @@ def test_header_vt_ff_whitespace
\r
HTTP
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
req.parse(StringIO.new(msg))
assert_equal("\x0b1\x0c \x0b2\x0c", req["Foo"])
end

Expand All @@ -147,7 +147,7 @@ def test_bare_cr_request_line
HTTP
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
assert_raise(WEBrick::HTTPStatus::BadRequest){
req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
req.parse(StringIO.new(msg))
}
end

Expand All @@ -159,7 +159,7 @@ def test_bare_cr_header
HTTP
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
assert_raise(WEBrick::HTTPStatus::BadRequest){
req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
req.parse(StringIO.new(msg))
}
end

Expand All @@ -171,7 +171,7 @@ def test_invalid_request_lines
HTTP
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
assert_raise(WEBrick::HTTPStatus::BadRequest){
req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
req.parse(StringIO.new(msg))
}

msg = <<~HTTP.gsub("\n", "\r\n")
Expand All @@ -181,7 +181,7 @@ def test_invalid_request_lines
HTTP
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
assert_raise(WEBrick::HTTPStatus::BadRequest){
req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
req.parse(StringIO.new(msg))
}

msg = <<~HTTP.gsub("\n", "\r\n")
Expand All @@ -191,7 +191,7 @@ def test_invalid_request_lines
HTTP
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
assert_raise(WEBrick::HTTPStatus::BadRequest){
req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
req.parse(StringIO.new(msg))
}

msg = <<~HTTP.gsub("\n", "\r\n")
Expand All @@ -201,7 +201,7 @@ def test_invalid_request_lines
HTTP
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
assert_raise(WEBrick::HTTPStatus::BadRequest){
req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
req.parse(StringIO.new(msg))
}
end

Expand Down Expand Up @@ -427,7 +427,6 @@ def test_null_byte_in_header
Evil: evil\x00\r
\r
HTTP
msg.gsub!(/^ {6}/, "")
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
assert_raise(WEBrick::HTTPStatus::BadRequest){ req.parse(StringIO.new(msg)) }
end
Expand Down

0 comments on commit e4efb4a

Please sign in to comment.