aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/journey/router
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2014-04-20 10:08:32 +0100
committerAndrew White <andyw@pixeltrix.co.uk>2014-04-20 10:11:38 +0100
commit5460591f0226a9d248b7b4f89186bd5553e7768f (patch)
tree95a96328aee8a38aec6e219b382e370c3a64a880 /actionpack/test/journey/router
parenta61792574d9c8904590895f7a2f56803e02a6c52 (diff)
downloadrails-5460591f0226a9d248b7b4f89186bd5553e7768f.tar.gz
rails-5460591f0226a9d248b7b4f89186bd5553e7768f.tar.bz2
rails-5460591f0226a9d248b7b4f89186bd5553e7768f.zip
Make URL escaping more consistent
1. Escape '%' characters in URLs - only unescaped data should be passed to URL helpers 2. Add an `escape_segment` helper to `Router::Utils` that escapes '/' characters 3. Use `escape_segment` rather than `escape_fragment` in optimized URL generation 4. Use `escape_segment` rather than `escape_path` in URL generation For point 4 there are two exceptions. Firstly, when a route uses wildcard segments (e.g. *foo) then we use `escape_path` as the value may contain '/' characters. This means that wildcard routes can't be optimized. Secondly, if a `:controller` segment is used in the path then this uses `escape_path` as the controller may be namespaced. Fixes #14629, #14636 and #14070.
Diffstat (limited to 'actionpack/test/journey/router')
-rw-r--r--actionpack/test/journey/router/utils_test.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/actionpack/test/journey/router/utils_test.rb b/actionpack/test/journey/router/utils_test.rb
index 8b3a4e340a..584fd56a5c 100644
--- a/actionpack/test/journey/router/utils_test.rb
+++ b/actionpack/test/journey/router/utils_test.rb
@@ -8,6 +8,10 @@ module ActionDispatch
assert_equal "a/b%20c+d%25", Utils.escape_path("a/b c+d%")
end
+ def test_segment_escape
+ assert_equal "a%2Fb%20c+d%25", Utils.escape_segment("a/b c+d%")
+ end
+
def test_fragment_escape
assert_equal "a/b%20c+d%25?e", Utils.escape_fragment("a/b c+d%?e")
end