aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/journey/router/utils.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_dispatch/journey/router/utils.rb')
-rw-r--r--actionpack/lib/action_dispatch/journey/router/utils.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/journey/router/utils.rb b/actionpack/lib/action_dispatch/journey/router/utils.rb
index 246d91da01..ac4ecb1e65 100644
--- a/actionpack/lib/action_dispatch/journey/router/utils.rb
+++ b/actionpack/lib/action_dispatch/journey/router/utils.rb
@@ -37,6 +37,7 @@ module ActionDispatch
ESCAPED = /%[a-zA-Z0-9]{2}/.freeze
FRAGMENT = /[^#{UNRESERVED}#{SUB_DELIMS}:@\/\?]/.freeze
+ SEGMENT = /[^#{UNRESERVED}#{SUB_DELIMS}:@]/.freeze
PATH = /[^#{UNRESERVED}#{SUB_DELIMS}:@\/]/.freeze
def escape_fragment(fragment)
@@ -47,6 +48,10 @@ module ActionDispatch
escape(path, PATH)
end
+ def escape_segment(segment)
+ escape(segment, SEGMENT)
+ end
+
def unescape_uri(uri)
uri.gsub(ESCAPED) { [$&[1, 2].hex].pack('C') }.force_encoding(uri.encoding)
end
@@ -69,6 +74,10 @@ module ActionDispatch
ENCODER.escape_path(path.to_s)
end
+ def self.escape_segment(segment)
+ ENCODER.escape_segment(segment.to_s)
+ end
+
def self.escape_fragment(fragment)
ENCODER.escape_fragment(fragment.to_s)
end