diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-02-21 10:05:07 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-02-21 10:05:07 +0000 |
commit | de0a0d700e8c3959a3503152b9a495616afbeae5 (patch) | |
tree | 0044f82e2220295c1244996d333afb822730c854 /actionpack/lib | |
parent | f29857690fee7fa8350f79922e349669480c0329 (diff) | |
download | rails-de0a0d700e8c3959a3503152b9a495616afbeae5.tar.gz rails-de0a0d700e8c3959a3503152b9a495616afbeae5.tar.bz2 rails-de0a0d700e8c3959a3503152b9a495616afbeae5.zip |
Routing: better support for escaped values in route segments. Closes #7544.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6185 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/routing.rb | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index 58207eed74..723aaada83 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -412,7 +412,7 @@ module ActionController def recognition_extraction next_capture = 1 extraction = segments.collect do |segment| - x = segment.match_extraction next_capture + x = segment.match_extraction(next_capture) next_capture += Regexp.new(segment.regexp_chunk).number_of_captures x end @@ -694,7 +694,7 @@ module ActionController end def interpolation_chunk - "\#{URI.escape(#{local_name}.to_s)}" + "\#{CGI.escape(#{local_name}.to_s)}" end def string_structure(prior_segments) @@ -725,10 +725,17 @@ module ActionController optional? ? Regexp.optionalize(pattern) : pattern end def match_extraction(next_capture) - hangon = (default ? "|| #{default.inspect}" : "if match[#{next_capture}]") - # All non code-related keys (such as :id, :slug) have to be unescaped as other CGI params - "params[:#{key}] = match[#{next_capture}] #{hangon}" + default_value = default ? default.inspect : nil + %[ + value = if (m = match[#{next_capture}]) + m = m.gsub('+', '%2B') + CGI.unescape(m) + else + #{default_value} + end + params[:#{key}] = value if value + ] end def optionality_implied? @@ -1292,7 +1299,6 @@ module ActionController end def recognize_path(path, environment={}) - path = URI.unescape(path) routes.each do |route| result = route.recognize(path, environment) and return result end |