Skip to content

Commit

Permalink
dup PATH_INFO before building REQUEST_URI from it
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Jan 21, 2010
1 parent 5f6dbb5 commit 60eeefa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/rack/openid.rb
Expand Up @@ -136,7 +136,7 @@ def sanitize_query_string(env)
Rack::Utils.build_query(env["rack.request.query_hash"])

qs = env["QUERY_STRING"]
request_uri = env["PATH_INFO"]
request_uri = env["PATH_INFO"].dup
request_uri << "?" + qs unless qs == ""
env["REQUEST_URI"] = request_uri
end
Expand Down
15 changes: 14 additions & 1 deletion test/test_openid.rb
Expand Up @@ -177,13 +177,26 @@ def test_with_timeout
assert_equal 'missing', @response.body
end

def test_sanitize_query_string
@app = app
process('/', :method => 'GET')
follow_redirect!
assert_equal 200, @response.status
assert_equal '/', @response.headers['X-Path']
assert_equal '', @response.headers['X-Query-String']
end

private
def app(options = {})
options[:identifier] ||= "#{RotsServer}/john.doe?openid.success=true"

app = lambda { |env|
if resp = env[Rack::OpenID::RESPONSE]
headers = {'X-Path' => env['PATH_INFO'], 'X-Method' => env['REQUEST_METHOD']}
headers = {
'X-Path' => env['PATH_INFO'],
'X-Method' => env['REQUEST_METHOD'],
'X-Query-String' => env['QUERY_STRING']
}
if resp.status == :success
[200, headers, [resp.status.to_s]]
else
Expand Down

0 comments on commit 60eeefa

Please sign in to comment.