Don't assume that invalid UTF-8 will raise an error.

Rack 3 parses the query part of a URL as ASCII-8BIT and does not fail on
invalid UTF-8 code sequences. Limit the tests to Rack 2.
This commit is contained in:
Samuel Williams 2023-01-21 05:51:29 +13:00
parent 5b9a246013
commit fd48e72518
No known key found for this signature in database
GPG Key ID: A0765423A44728FB
1 changed files with 13 additions and 11 deletions

View File

@ -1129,19 +1129,21 @@ class RequestParameters < BaseRequestTest
end
end
test "parameters not accessible after rack parse error of invalid UTF8 character" do
request = stub_request("QUERY_STRING" => "foo%81E=1")
assert_raises(ActionController::BadRequest) { request.parameters }
end
if Rack.release < "3"
test "parameters not accessible after rack parse error of invalid UTF8 character" do
request = stub_request("QUERY_STRING" => "foo%81E=1")
assert_raises(ActionController::BadRequest) { request.parameters }
end
test "parameters containing an invalid UTF8 character" do
request = stub_request("QUERY_STRING" => "foo=%81E")
assert_raises(ActionController::BadRequest) { request.parameters }
end
test "parameters containing an invalid UTF8 character" do
request = stub_request("QUERY_STRING" => "foo=%81E")
assert_raises(ActionController::BadRequest) { request.parameters }
end
test "parameters containing a deeply nested invalid UTF8 character" do
request = stub_request("QUERY_STRING" => "foo[bar]=%81E")
assert_raises(ActionController::BadRequest) { request.parameters }
test "parameters containing a deeply nested invalid UTF8 character" do
request = stub_request("QUERY_STRING" => "foo[bar]=%81E")
assert_raises(ActionController::BadRequest) { request.parameters }
end
end
test "POST parameters containing invalid UTF8 character" do