better NoReferrer check

This commit is contained in:
Konstantin Haase 2011-06-19 15:26:21 +02:00
parent a4f827e9b4
commit ec0df5969b
2 changed files with 2 additions and 2 deletions

View File

@ -16,7 +16,7 @@ module Rack
default_reaction :deny
def accepts?(env)
safe?(env) or referrer(env)
safe?(env) or not env['HTTP_REFERER'].to_s.empty?
end
end
end

View File

@ -15,7 +15,7 @@ describe Rack::Protection::NoReferrer do
post('/', {}, 'HTTP_REFERER' => 'http://google.com').should be_ok
end
it "should allow post request with an empty referrer" do
it "should not allow post request with an empty referrer" do
post('/', {}, 'HTTP_REFERER' => '').should_not be_ok
end
end