aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb b/activesupport/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb
new file mode 100644
index 0000000000..a21e98fa80
--- /dev/null
+++ b/activesupport/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb
@@ -0,0 +1,14 @@
+module ActiveSupport #:nodoc:
+ module CoreExtensions #:nodoc:
+ module CGI #:nodoc:
+ module EscapeSkippingSlashes #:nodoc:
+ def escape_skipping_slashes(str)
+ str = str.join('/') if str.respond_to? :join
+ str.gsub(/([^ \/a-zA-Z0-9_.-])/n) do
+ "%#{$1.unpack('H2').first.upcase}"
+ end.tr(' ', '+')
+ end
+ end
+ end
+ end
+end