Added URL escaping of user and password when used through the UrlWriter

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6314 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 a7520990
......@@ -111,7 +111,7 @@ def rewrite_path(options)
def rewrite_authentication(options)
if options[:user] && options[:password]
"#{options.delete(:user)}:#{options.delete(:password)}@"
"#{CGI.escape(options.delete(:user))}:#{CGI.escape(options.delete(:password))}@"
else
""
end
......
......@@ -29,7 +29,14 @@ def test_user_name_and_password
@rewriter.rewrite(:user => "david", :password => "secret", :controller => 'c', :action => 'a', :id => 'i')
)
end
def test_user_name_and_password_with_escape_codes
assert_equal(
'http://openid.aol.com%2Fnextangler:one+two%3F@test.host/c/a/i',
@rewriter.rewrite(:user => "openid.aol.com/nextangler", :password => "one two?", :controller => 'c', :action => 'a', :id => 'i')
)
end
def test_overwrite_params
@params[:controller] = 'hi'
@params[:action] = 'bye'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册