diff options
author | Chris Roos <chrisjroos@gmail.com> | 2008-05-10 14:55:11 +1200 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2008-05-10 14:55:41 +1200 |
commit | 6776edccf6fb553eb0ac6db55e1d30df1b5b6589 (patch) | |
tree | 0a3f2c239d1e316db4ab2d9b7532b0da679365aa /actionpack/lib/action_controller/routing | |
parent | dc4eec1129520ce9863c9373d7cb79d8636ab7ca (diff) | |
download | rails-6776edccf6fb553eb0ac6db55e1d30df1b5b6589.tar.gz rails-6776edccf6fb553eb0ac6db55e1d30df1b5b6589.tar.bz2 rails-6776edccf6fb553eb0ac6db55e1d30df1b5b6589.zip |
Escape globbed parameters in routes correctly.
:controller => 'glob', :action=> 'show', :additional => ['foo/bar', 'baz']
Should generate /glob/show/foo%2Fbar/baz not /glob/show/foo/bar/baz
Diffstat (limited to 'actionpack/lib/action_controller/routing')
-rw-r--r-- | actionpack/lib/action_controller/routing/segments.rb | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/actionpack/lib/action_controller/routing/segments.rb b/actionpack/lib/action_controller/routing/segments.rb index 24ea8c7f2d..b142d18b47 100644 --- a/actionpack/lib/action_controller/routing/segments.rb +++ b/actionpack/lib/action_controller/routing/segments.rb @@ -244,11 +244,12 @@ module ActionController end class PathSegment < DynamicSegment #:nodoc: - RESERVED_PCHAR = "#{Segment::RESERVED_PCHAR}/" - UNSAFE_PCHAR = Regexp.new("[^#{URI::REGEXP::PATTERN::UNRESERVED}#{RESERVED_PCHAR}]", false, 'N').freeze - def interpolation_chunk(value_code = "#{local_name}") - "\#{URI.escape(#{value_code}.to_s, ActionController::Routing::PathSegment::UNSAFE_PCHAR)}" + "\#{#{value_code}}" + end + + def extract_value + "#{local_name} = hash[:#{key}] && hash[:#{key}].collect { |path_component| URI.escape(path_component, ActionController::Routing::Segment::UNSAFE_PCHAR) }.to_param #{"|| #{default.inspect}" if default}" end def default |