mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Eliminate newlines in basic auth. fixes #2882
This commit is contained in:
parent
54b7e783ef
commit
f6ced69a11
2 changed files with 9 additions and 1 deletions
|
@ -145,7 +145,7 @@ module ActionController
|
||||||
end
|
end
|
||||||
|
|
||||||
def encode_credentials(user_name, password)
|
def encode_credentials(user_name, password)
|
||||||
"Basic #{ActiveSupport::Base64.encode64("#{user_name}:#{password}")}"
|
"Basic #{ActiveSupport::Base64.encode64s("#{user_name}:#{password}")}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def authentication_request(controller, realm)
|
def authentication_request(controller, realm)
|
||||||
|
|
|
@ -85,6 +85,14 @@ class HttpBasicAuthenticationTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_encode_credentials_has_no_newline
|
||||||
|
username = 'laskjdfhalksdjfhalkjdsfhalksdjfhklsdjhalksdjfhalksdjfhlakdsjfh'
|
||||||
|
password = 'kjfhueyt9485osdfasdkljfh4lkjhakldjfhalkdsjf'
|
||||||
|
result = ActionController::HttpAuthentication::Basic.encode_credentials(
|
||||||
|
username, password)
|
||||||
|
assert_no_match(/\n/, result)
|
||||||
|
end
|
||||||
|
|
||||||
test "authentication request without credential" do
|
test "authentication request without credential" do
|
||||||
get :display
|
get :display
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue