Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Plus symbols in the URL should be converted to spaces when considered…

… as param values.

Closes #463.
  • Loading branch information...
commit 311aa4264600b324978d36e01c82755bf17246e0 1 parent 94707f5
@boucher authored
Showing with 12 additions and 1 deletion.
  1. +1 −1  lib/sinatra/base.rb
  2. +11 −0 test/routing_test.rb
View
2  lib/sinatra/base.rb
@@ -825,7 +825,7 @@ def process_route(pattern, keys, conditions, block = nil, values = [])
route = @request.path_info
route = '/' if route.empty? and not settings.empty_path_info?
return unless match = pattern.match(route)
- values += match.captures.to_a.map { |v| force_encoding URI.decode(v) if v }
+ values += match.captures.to_a.map { |v| force_encoding URI.decode_www_form_component(v) if v }
if values.any?
original, @params = params, params.merge('splat' => [], 'captures' => values)
View
11 test/routing_test.rb
@@ -329,6 +329,17 @@ class RoutingTest < Test::Unit::TestCase
assert not_found?
end
+ it "converts plus sign into space as the value of a named param" do
+ mock_app {
+ get '/:test' do
+ params["test"]
+ end
+ }
+ get '/bob+ross'
+ assert ok?
+ assert_equal 'bob ross', body
+ end
+
it "literally matches parens in paths" do
route_def '/test(bar)/'
Please sign in to comment.
Something went wrong with that request. Please try again.