-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Open
Labels
A-needs-triagingA Selenium member will evaluate this soon!A Selenium member will evaluate this soon!C-pyPython BindingsPython BindingsI-defectSomething is not working as intendedSomething is not working as intendedOS-windows
Description
Description
Description:
When using a proxy server that requires authentication where the password contains special characters (like #
), the authentication fails because:
- The password gets URL-encoded when creating the proxy URL string
- The encoded password then gets base64-encoded in headers, causing authentication failure
Expected Behavior:
Proxy authentication should work with passwords containing special characters when properly encoded.
Actual Behavior:
Authentication fails with 407 error when proxy password contains special characters because:
Root Cause:
- In RemoteConnection._separate_http_proxy_auth(), an error will be thrown if special characters (like
#
) are not URL-encoded, because these characters are used as delimiters during URL parsing. Hence, URL encoding is required for credentials with special characters. - In RemoteConnection._get_connection_manager(), urllib3.make_headers() base64-encodes the already-encoded password, without decoding it.
- The proxy server receives passw%23rd instead of passw#rd as the base64 Authorisation header.
Suggested Fix:
The password should be URL-unquoted before being passed to make_headers() for base64 encoding. The fix would involve adding urllib.parse.unquote() for the password component in _get_connection_manager().
Reproducible Code
def test_selenium_webdriver():
hub_url = "http://abc.perfectomobile.com/nexperience/perfectomobile/wd/hub"
proxy = Proxy(
{
"proxyType": ProxyType.MANUAL,
"httpProxy": "http://user:passw%[email protected]:8080", # passwo#rd in URL encoded format
}
)
options = webdriver.ChromeOptions()
client_config = ClientConfig(hub_url, proxy=proxy)
connection = RemoteConnection(client_config=client_config)
driver = webdriver.Remote(connection, options=options)
assert driver.session_id
Metadata
Metadata
Assignees
Labels
A-needs-triagingA Selenium member will evaluate this soon!A Selenium member will evaluate this soon!C-pyPython BindingsPython BindingsI-defectSomething is not working as intendedSomething is not working as intendedOS-windows