Skip to content

Commit

Permalink
Revert "Correctly handle encoded colons in routes (Fixes #776)"
Browse files Browse the repository at this point in the history
This reverts commit bd8e07f.
  • Loading branch information
Zachary Scott committed Mar 24, 2015
1 parent b0bd782 commit ca5b2f1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 45 deletions.
2 changes: 1 addition & 1 deletion lib/sinatra/base.rb
Expand Up @@ -1631,7 +1631,7 @@ def compile(path)

# Special character handling.
#
pattern = segment.to_str.gsub(/[^\?\%\\\/\:\*\w]|:(?!\w)/) do |c|
pattern = segment.to_str.gsub(/[^\?\%\\\/\:\*\w]/) do |c|
ignore << escaped(c).join if c.match(/[\.@]/)
patt = encoded(c)
patt.gsub(/%[\da-fA-F]{2}/) do |match|
Expand Down
44 changes: 0 additions & 44 deletions test/routing_test.rb
Expand Up @@ -99,50 +99,6 @@ class RoutingTest < Minitest::Test
assert_body "foo/bar"
end

it "it handles encoded colons correctly" do
mock_app {
get("/:") { 'a' }
get("/a/:") { 'b' }
get("/a/:/b") { 'c' }
get("/a/b:") { 'd' }
get("/a/b: ") { 'e' }
}
get '/:'
assert_equal 200, status
assert_body "a"
get '/%3a'
assert_equal 200, status
assert_body "a"

get '/a/:'
assert_equal 200, status
assert_body "b"
get '/a/%3a'
assert_equal 200, status
assert_body "b"

get '/a/:/b'
assert_equal 200, status
assert_body "c"
get '/a/%3A/b'
assert_equal 200, status
assert_body "c"

get '/a/b:'
assert_equal 200, status
assert_body "d"
get '/a/b%3a'
assert_equal 200, status
assert_body "d"

get '/a/b%3a%20'
assert_equal 200, status
assert_body "e"
get '/a/b%3a+'
assert_equal 200, status
assert_body "e"
end

it "overrides the content-type in error handlers" do
mock_app {
before { content_type 'text/plain' }
Expand Down

0 comments on commit ca5b2f1

Please sign in to comment.