如何获取在Sinatra中传递给我的处理程序的实际编码URL?
我有一个网址 - 注意有/后面跟着一个双斜线编码..
http://someplace.com/thing/blah/%2F%2Fxxx.png
get '/thing/*/*' do
begin
# would like this to work but it does not. Sinatra 1.4.4, ruby 2.0.0
first = CGI.unescape(params[:splat][0])
path = CGI.unescape(params[:splat][1])
# path does NOT have a double // (%2F%2F),
# it has all of them ripped off by some rack code, I think
# TRY get actual URL and parse by myself...
the_url = request.url # this is already urldecoded and is missing the double //
the_query_path = request.env["rack.request.query_string"]; # blank for me?
由于
答案 0 :(得分:1)
https://github.com/sinatra/sinatra/issues/808
好的 - 我知道 - 那份报告是6个月前发给我的。正如您所看到的,他们在splats上添加了保护措施,以阻止攻击者进入您的文件系统。
在app config部分中:
set :protection, :except => :path_traversal
现在你失去了这种保护......在我的情况下,这些路径与ruby服务器不在同一台机器上。
知道如何获取服务器被击中的实际网址仍然很方便,可能还有一些机架环境。