Skip to content

changing basic_auth_header flavor to b64encode instead of urlsafe_b64encode #192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_basic_auth_header(self):
)
# Check url unsafe encoded header
self.assertEqual(
b"Basic c29tZXVzZXI6QDx5dTk-Jm8_UQ==",
b"Basic c29tZXVzZXI6QDx5dTk+Jm8/UQ==",
basic_auth_header("someuser", "@<yu9>&o?Q"),
)

Expand All @@ -28,7 +28,7 @@ def test_basic_auth_header_encoding(self):
)
# default encoding (ISO-8859-1)
self.assertEqual(
b"Basic c29t5nVz6HI6c_htZXDkc3M=", basic_auth_header("somæusèr", "sømepäss")
b"Basic c29t5nVz6HI6c/htZXDkc3M=", basic_auth_header("somæusèr", "sømepäss")
)

def test_headers_raw_dict_none(self):
Expand Down
4 changes: 2 additions & 2 deletions w3lib/http.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from base64 import urlsafe_b64encode
from base64 import b64encode
from typing import Any, List, MutableMapping, Optional, AnyStr, Sequence, Union, Mapping
from w3lib.util import to_bytes, to_unicode

Expand Down Expand Up @@ -101,4 +101,4 @@ def basic_auth_header(
# XXX: RFC 2617 doesn't define encoding, but ISO-8859-1
# seems to be the most widely used encoding here. See also:
# http://greenbytes.de/tech/webdav/draft-ietf-httpauth-basicauth-enc-latest.html
return b"Basic " + urlsafe_b64encode(to_bytes(auth, encoding=encoding))
return b"Basic " + b64encode(to_bytes(auth, encoding=encoding))