Monkey patch escaping in redirect routes
authorTom Hughes <tom@compton.nu>
Sat, 30 Nov 2013 13:46:07 +0000 (13:46 +0000)
committerTom Hughes <tom@compton.nu>
Sat, 30 Nov 2013 13:53:48 +0000 (13:53 +0000)
The correct method of escaping depends on whether the parameter
is being substituted in the path or the query, but all our ones
are substitued in the path so use URI.escape instead of the
standard Rack::Utils.escape which does query escaping.

https://github.com/rails/rails/issues/13110

config/initializers/routing_redirect.rb [new file with mode: 0644]

diff --git a/config/initializers/routing_redirect.rb b/config/initializers/routing_redirect.rb
new file mode 100644 (file)
index 0000000..d064472
--- /dev/null
@@ -0,0 +1,16 @@
+require "action_dispatch/routing/redirection"
+
+#
+# Fix escaping in routes to use path style escaping
+#
+# https://github.com/rails/rails/issues/13110
+#
+module ActionDispatch
+  module Routing
+    class PathRedirect < Redirect
+      def escape(params)
+        Hash[params.map{ |k,v| [k, URI.escape(v)] }]
+      end
+    end
+  end
+end