1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00

fixed escaped paths not resolving static files [Matthew Walker]

Signed-off-by: Blake Mizerany <blakemizerany@blake.local>
This commit is contained in:
Blake Mizerany 2008-04-26 15:09:40 -07:00
parent 9c875ffda0
commit d16ee6533b
2 changed files with 13 additions and 5 deletions

View file

@ -5,9 +5,9 @@ end
require 'rack'
require 'rubygems'
require 'uri'
require 'time'
require 'ostruct'
require "uri"
if ENV['SWIFT']
require 'swiftcore/swiftiplied_mongrel'
@ -217,14 +217,14 @@ module Sinatra
def invoke(request)
return unless File.file?(
Sinatra.application.options.public + request.path_info
Sinatra.application.options.public + request.path_info.http_unescape
)
Result.new(block, {}, 200)
end
def block
Proc.new do
send_file Sinatra.application.options.public + request.path_info,
send_file Sinatra.application.options.public + request.path_info.http_unescape,
:disposition => nil
end
end
@ -1174,14 +1174,16 @@ class String
# Converts +self+ to an escaped URI parameter value
# 'Foo Bar'.to_param # => 'Foo%20Bar'
def to_param
URI.escape(self)
Rack::Utils.escape(self)
end
alias :http_escape :to_param
# Converts +self+ from an escaped URI parameter value
# 'Foo%20Bar'.from_param # => 'Foo Bar'
def from_param
URI.unescape(self)
Rack::Utils.unescape(self)
end
alias :http_unescape :from_param
end

View file

@ -77,6 +77,12 @@ context "Static files (by default)" do
headers['Content-Transfer-Encoding'].should.be.nil
end
specify "should be served even if their path is url escaped" do
get_it('/fo%6f.xml')
should.be.ok
body.should.equal "<foo></foo>\n"
end
end
context "SendData" do