public
Rubygem
Description: Classy web-development dressed in a DSL
Homepage: http://sinatrarb.com
Clone URL: git://github.com/bmizerany/sinatra.git
fixed escaped paths not resolving static files [Matthew Walker]

Signed-off-by: Blake Mizerany <blakemizerany@blake.local>
Blake Mizerany (author)
Sat Apr 26 15:09:40 -0700 2008
commit  d16ee6533b01cda980a6311019d6f13efe109e6b
tree    4ca74524d7f11697859b4682b8dbbc97ef5c6c18
parent  9c875ffda0d9d12bd54f83606b30601b1b9b6bf7
...
5
6
7
8
9
10
 
11
12
13
...
217
218
219
220
 
221
222
223
224
225
226
227
 
228
229
230
...
1174
1175
1176
1177
 
1178
 
1179
1180
1181
1182
1183
 
1184
 
1185
1186
1187
...
5
6
7
 
8
9
10
11
12
13
...
217
218
219
 
220
221
222
223
224
225
226
 
227
228
229
230
...
1174
1175
1176
 
1177
1178
1179
1180
1181
1182
1183
 
1184
1185
1186
1187
1188
1189
0
@@ -5,9 +5,9 @@ end
0
 require 'rack'
0
 
0
 require 'rubygems'
0
-require 'uri'
0
 require 'time'
0
 require 'ostruct'
0
+require "uri"
0
 
0
 if ENV['SWIFT']
0
  require 'swiftcore/swiftiplied_mongrel'
0
@@ -217,14 +217,14 @@ module Sinatra
0
             
0
     def invoke(request)
0
       return unless File.file?(
0
- Sinatra.application.options.public + request.path_info
0
+ Sinatra.application.options.public + request.path_info.http_unescape
0
       )
0
       Result.new(block, {}, 200)
0
     end
0
     
0
     def block
0
       Proc.new do
0
- send_file Sinatra.application.options.public + request.path_info,
0
+ send_file Sinatra.application.options.public + request.path_info.http_unescape,
0
           :disposition => nil
0
       end
0
     end
0
@@ -1174,14 +1174,16 @@ class String
0
   # Converts +self+ to an escaped URI parameter value
0
   # 'Foo Bar'.to_param # => 'Foo%20Bar'
0
   def to_param
0
- URI.escape(self)
0
+ Rack::Utils.escape(self)
0
   end
0
+ alias :http_escape :to_param
0
   
0
   # Converts +self+ from an escaped URI parameter value
0
   # 'Foo%20Bar'.from_param # => 'Foo Bar'
0
   def from_param
0
- URI.unescape(self)
0
+ Rack::Utils.unescape(self)
0
   end
0
+ alias :http_unescape :from_param
0
   
0
 end
0
 
...
77
78
79
 
 
 
 
 
 
80
81
82
...
77
78
79
80
81
82
83
84
85
86
87
88
0
@@ -77,6 +77,12 @@ context "Static files (by default)" do
0
     headers['Content-Transfer-Encoding'].should.be.nil
0
   end
0
 
0
+ specify "should be served even if their path is url escaped" do
0
+ get_it('/fo%6f.xml')
0
+ should.be.ok
0
+ body.should.equal "<foo></foo>\n"
0
+ end
0
+
0
 end
0
 
0
 context "SendData" do

Comments

    No one has commented yet.