Skip to content
Browse files

Eliminate newlines in basic auth. fixes #2882

  • Loading branch information...
1 parent 54b7e78 commit f6ced69a11cdff56c2e87b84e775ef09c6d999d1 @tenderlove tenderlove committed Sep 6, 2011
View
2 actionpack/lib/action_controller/metal/http_authentication.rb
@@ -145,7 +145,7 @@ def decode_credentials(request)
end
def encode_credentials(user_name, password)
- "Basic #{ActiveSupport::Base64.encode64("#{user_name}:#{password}")}"
+ "Basic #{ActiveSupport::Base64.encode64s("#{user_name}:#{password}")}"
end
def authentication_request(controller, realm)
View
8 actionpack/test/controller/http_basic_authentication_test.rb
@@ -85,6 +85,14 @@ def authenticate_long_credentials
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
get :display

0 comments on commit f6ced69

Please sign in to comment.
Something went wrong with that request. Please try again.