aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/routing_test.rb
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2017-08-01 13:02:53 -0400
committereileencodes <eileencodes@gmail.com>2017-08-01 13:28:57 -0400
commit92209356c310caabda8665d6369d3b1e4a1800d1 (patch)
tree58f91bdfba733804b53a64ebfbd5770af35f68c8 /actionpack/test/dispatch/routing_test.rb
parent030c66a51faf9f43bfc6093ed6cc119e9a09a09a (diff)
downloadrails-92209356c310caabda8665d6369d3b1e4a1800d1.tar.gz
rails-92209356c310caabda8665d6369d3b1e4a1800d1.tar.bz2
rails-92209356c310caabda8665d6369d3b1e4a1800d1.zip
Path parameters should default to UTF8
This commit changes the behavior such the path_params now default to UTF8 just like regular parameters. This also changes the behavior such that if a path parameter contains invalid UTF8 it returns a 400 bad request. Previously the behavior was to encode the path params as binary but that's not the same as query params. So this commit makes path params behave the same as query params. It's important to test with a path that's encoded as binary because that's how paths are encoded from the socket. The test that was altered was changed to make the behavior for bad encoding the same as query params. We want to treat path params the same as query params. The params in the test are invalid UTF8 so they should return a bad request. Fixes #29669 *Eileen M. Uchitelle, Aaron Patterson, & Tsukuru Tanimichi*
Diffstat (limited to 'actionpack/test/dispatch/routing_test.rb')
-rw-r--r--actionpack/test/dispatch/routing_test.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 1af0edc1d3..2bb814e5f4 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -4416,6 +4416,10 @@ end
class TestInvalidUrls < ActionDispatch::IntegrationTest
class FooController < ActionController::Base
+ def self.binary_params_for?(action)
+ action == "show"
+ end
+
def show
render plain: "foo#show"
end
@@ -4437,19 +4441,19 @@ class TestInvalidUrls < ActionDispatch::IntegrationTest
end
get "/%E2%EF%BF%BD%A6"
- assert_response :not_found
+ assert_response :bad_request
get "/foo/%E2%EF%BF%BD%A6"
- assert_response :not_found
+ assert_response :bad_request
get "/foo/show/%E2%EF%BF%BD%A6"
assert_response :ok
get "/bar/%E2%EF%BF%BD%A6"
- assert_response :redirect
+ assert_response :bad_request
get "/foobar/%E2%EF%BF%BD%A6"
- assert_response :ok
+ assert_response :bad_request
end
end
end