aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/routing_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/dispatch/routing_test.rb')
-rw-r--r--actionpack/test/dispatch/routing_test.rb30
1 files changed, 21 insertions, 9 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 32cd78e492..446b65a9b9 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require "erb"
require "abstract_unit"
require "controller/fake_controllers"
@@ -4414,39 +4416,49 @@ 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
end
- test "invalid UTF-8 encoding is treated as ASCII 8BIT encode" do
+ test "invalid UTF-8 encoding returns a bad request" do
with_routing do |set|
set.draw do
get "/bar/:id", to: redirect("/foo/show/%{id}")
- get "/foo/show(/:id)", to: "test_invalid_urls/foo#show"
ok = lambda { |env| [200, { "Content-Type" => "text/plain" }, []] }
get "/foobar/:id", to: ok
ActiveSupport::Deprecation.silence do
- get "/foo(/:action(/:id))", controller: "test_invalid_urls/foo"
get "/:controller(/:action(/:id))"
end
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
-
- get "/foo/show/%E2%EF%BF%BD%A6"
- assert_response :ok
+ assert_response :bad_request
get "/bar/%E2%EF%BF%BD%A6"
- assert_response :redirect
+ assert_response :bad_request
get "/foobar/%E2%EF%BF%BD%A6"
+ assert_response :bad_request
+ end
+ end
+
+ test "params encoded with binary_params_for? are treated as ASCII 8bit" do
+ with_routing do |set|
+ set.draw do
+ get "/foo/show(/:id)", to: "test_invalid_urls/foo#show"
+ end
+
+ get "/foo/show/%E2%EF%BF%BD%A6"
assert_response :ok
end
end