Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An Encoded forward slash is being handled as if it was un-encoded - Sinatra

Tags:

url

ruby

sinatra

I have a Sinatra route like

get 'check/:input' do |in|
   ##Do stuff in here
end

but when I put a string in :input that contains a forward slash, such as "abcde/12345" or even encoded like "abcde%2F12345", Sinatra is thinking I am trying to reach

check/abcde/12345

and I hit the standard Sinatra 404 page. How do I get around this? I need the slash in the input variable, so I can't simply trim it out or anything like that. Any help would be greatly appreciated!!

like image 599
Scott Avatar asked Dec 20 '25 23:12

Scott


1 Answers

This is done deliberately as part of rack-protection’s path traversal protection.

To disable it you can do

set :protection, :except => :path_traversal
like image 86
matt Avatar answered Dec 24 '25 10:12

matt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!