From 9f38a3fb0c9c71102da283b014503ccad92da581 Mon Sep 17 00:00:00 2001 From: Grey Baker Date: Wed, 13 Jul 2016 18:44:04 +0100 Subject: Check `request.path_parameters` encoding at the point they're set Check for any non-UTF8 characters in path parameters at the point they're set in `env`. Previously they were checked for when used to get a controller class, but this meant routes that went directly to a Rack app, or skipped controller instantiation for some other reason, had to defend against non-UTF8 characters themselves. --- actionpack/test/dispatch/request_test.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'actionpack/test/dispatch/request_test.rb') diff --git a/actionpack/test/dispatch/request_test.rb b/actionpack/test/dispatch/request_test.rb index 8a5d85ab84..634f6d80c4 100644 --- a/actionpack/test/dispatch/request_test.rb +++ b/actionpack/test/dispatch/request_test.rb @@ -1018,17 +1018,13 @@ class RequestParameters < BaseRequestTest end test "path parameters with invalid UTF8 encoding" do - request = stub_request( - "action_dispatch.request.path_parameters" => { foo: "\xBE" } - ) + request = stub_request err = assert_raises(ActionController::BadRequest) do - request.check_path_parameters! + request.path_parameters = { foo: "\xBE" } end - assert_match "Invalid parameter encoding", err.message - assert_match "foo", err.message - assert_match "\\xBE", err.message + assert_equal "Invalid path parameters: Non UTF-8 value: \xBE", err.message end test "parameters not accessible after rack parse error of invalid UTF8 character" do -- cgit v1.2.3