lib/apipie/static_dispatcher.rb in apipie-rails-0.5.14 vs lib/apipie/static_dispatcher.rb in apipie-rails-0.5.15
- old
+ new
@@ -6,12 +6,13 @@
@compiled_root = /^#{Regexp.escape(root)}/
@file_server = ::Rack::File.new(@root)
end
def match?(path)
- path = path.dup
+ # Replace all null bytes
+ path = ::Rack::Utils.unescape(path || '').gsub(/\x0/, '')
- full_path = path.empty? ? @root : File.join(@root, ::Rack::Utils.unescape(path))
+ full_path = path.empty? ? @root : File.join(@root, path)
paths = "#{full_path}#{ext}"
matches = Dir[paths]
match = matches.detect { |m| File.file?(m) }
if match