Skip to content

Instantly share code, notes, and snippets.

@weiser
Created January 3, 2014 19:31
Show Gist options
  • Save weiser/8244851 to your computer and use it in GitHub Desktop.
Save weiser/8244851 to your computer and use it in GitHub Desktop.
This gist shows that rack is not decoding url-encoded paths
# my_app.rb
require 'sinatra/base' #at version a570335d99619e5ac00dc32825201e252895d613
class MyApp < Sinatra::Base
get '/:e/:l/:q/:d' do
puts "params are: #{[:e, :l, :q, :d].map{|p| params[p]}.join(' ')}"
end
get '/*.*' do
puts request
end
# start the server if ruby file executed directly
run! if app_file == $0
end
#end my_app.rb
# in one shell session, run `ruby my_app.rb`
# in another shell session, run `curl http://localhost:4567/e/l/http%3A%2F%2Fkdweb.com%2F/2014`
#I expect an HTTP 200 status to be returned from the /:e/:l/:q/:d endpoint, but the request (which has not been url-decoded) is printed from the /*.* endpoint.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment