diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-11-26 17:59:09 -0800 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-11-26 17:59:09 -0800 |
commit | 51e15a60b012562a46c692070f15ac9dcd4902b6 (patch) | |
tree | 575279f46b74a88318e39fdeeec76b58abb51d65 | |
parent | 5fa8c3b6db48c0be923e4572468493f162551336 (diff) | |
download | rails-51e15a60b012562a46c692070f15ac9dcd4902b6.tar.gz rails-51e15a60b012562a46c692070f15ac9dcd4902b6.tar.bz2 rails-51e15a60b012562a46c692070f15ac9dcd4902b6.zip |
Ruby 1.9 compat: CGI#escape_skipping_slashes
-rw-r--r-- | activesupport/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb | 19 |
1 files changed, 14 insertions, 5 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 index a21e98fa80..1edb3771a2 100644 --- a/activesupport/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +++ b/activesupport/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb @@ -2,11 +2,20 @@ 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(' ', '+') + if RUBY_VERSION >= '1.9' + def escape_skipping_slashes(str) + str = str.join('/') if str.respond_to? :join + str.gsub(/([^ \/a-zA-Z0-9_.-])/n) do + "%#{$1.unpack('H2' * $1.bytesize).join('%').upcase}" + end.tr(' ', '+') + end + else + 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 |