Hi,
We're trying to upgrade a Sinatra 1.4.X app to 2.0.X. It seems like URI paths get unescaped in Sinatra 1.4.X, but stay escaped in 2.0.X. Here is an example program to demonstrate the issue:
spec = eval "lambda { " + File.read("sinatra.gemspec") + "}.call"
spec.dependencies.each { |dep| gem dep.name, dep.requirement }
require "sinatra"
require "net/http"
expected = "foo\xE2\x80\x8Cbar".b
req_thread = Thread.new do
Thread.current.abort_on_exception = true
uri = URI.parse 'http://localhost:4567/contents/foo%e2%80%8cbar'
begin
actual = Net::HTTP.get_response(uri).body
if expected == actual
puts "great, it worked"
else
puts "Expected #{expected.dump} actual #{actual.dump}"
end
Process.kill 'INT', $$
rescue Errno::ECONNREFUSED
retry
end
end
get %r{/contents/(.+)} do |path|
path
end
If I run this program against the v1.4.8 tag, then the path value is "foo\xE2\x80\x8Cbar". But if I run against master (currently c8910e9), then the path value is still percent encoded as "foo%e2%80%8cbar".
Is this change intentional? The old behavior seems correct to me, otherwise I have to manually decode paths everywhere. If the change is intentional, what's the best way for me to get this behavior back (I'd like to get the behavior back without changing the code for every route).
Thanks for your time!! ❤️🧡💛💚💙💜🖤
Hi,
We're trying to upgrade a Sinatra 1.4.X app to 2.0.X. It seems like URI paths get unescaped in Sinatra 1.4.X, but stay escaped in 2.0.X. Here is an example program to demonstrate the issue:
If I run this program against the
v1.4.8tag, then the path value is"foo\xE2\x80\x8Cbar". But if I run against master (currently c8910e9), then the path value is still percent encoded as"foo%e2%80%8cbar".Is this change intentional? The old behavior seems correct to me, otherwise I have to manually decode paths everywhere. If the change is intentional, what's the best way for me to get this behavior back (I'd like to get the behavior back without changing the code for every route).
Thanks for your time!! ❤️🧡💛💚💙💜🖤