From 4491e2676d6c0b5615cee4205ab9092c0e616219 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Tue, 4 Oct 2011 14:54:47 -0700 Subject: [PATCH] deal with PATH_INFO being nil, fixes #7 --- rack-protection/lib/rack/protection/path_traversal.rb | 2 +- rack-protection/lib/rack/protection/version.rb | 2 +- rack-protection/rack-protection.gemspec | 2 +- rack-protection/spec/path_traversal_spec.rb | 5 +++++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/rack-protection/lib/rack/protection/path_traversal.rb b/rack-protection/lib/rack/protection/path_traversal.rb index 9a0ef478..8f087ee3 100644 --- a/rack-protection/lib/rack/protection/path_traversal.rb +++ b/rack-protection/lib/rack/protection/path_traversal.rb @@ -12,7 +12,7 @@ module Rack class PathTraversal < Base def call(env) path_was = env["PATH_INFO"] - env["PATH_INFO"] = cleanup path_was + env["PATH_INFO"] = cleanup path_was if path_was app.call env ensure env["PATH_INFO"] = path_was diff --git a/rack-protection/lib/rack/protection/version.rb b/rack-protection/lib/rack/protection/version.rb index feb98b07..0a603ce2 100644 --- a/rack-protection/lib/rack/protection/version.rb +++ b/rack-protection/lib/rack/protection/version.rb @@ -4,7 +4,7 @@ module Rack VERSION end - SIGNATURE = [1, 1, 2] + SIGNATURE = [1, 1, 4] VERSION = SIGNATURE.join('.') VERSION.extend Comparable diff --git a/rack-protection/rack-protection.gemspec b/rack-protection/rack-protection.gemspec index 9a1e304d..cddf953d 100644 --- a/rack-protection/rack-protection.gemspec +++ b/rack-protection/rack-protection.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |s| # general infos s.name = "rack-protection" - s.version = "1.1.2" + s.version = "1.1.4" s.description = "You should use protection!" s.homepage = "http://github.com/rkh/rack-protection" s.summary = s.description diff --git a/rack-protection/spec/path_traversal_spec.rb b/rack-protection/spec/path_traversal_spec.rb index e6ae161c..6b47705c 100644 --- a/rack-protection/spec/path_traversal_spec.rb +++ b/rack-protection/spec/path_traversal_spec.rb @@ -19,5 +19,10 @@ describe Rack::Protection::PathTraversal do }.each do |a, b| it("replaces #{a.inspect} with #{b.inspect}") { get(a).body.should == b } end + + it 'should be able to deal with PATH_INFO = nil (fcgi?)' do + app = Rack::Protection::PathTraversal.new(proc { 42 }) + app.call({}).should be == 42 + end end end