diff --git a/integration_tests/samples/socket_mode/builtin_proxy_auth_example.py b/integration_tests/samples/socket_mode/builtin_proxy_auth_example.py index 0254121e5..be65ddba2 100644 --- a/integration_tests/samples/socket_mode/builtin_proxy_auth_example.py +++ b/integration_tests/samples/socket_mode/builtin_proxy_auth_example.py @@ -14,8 +14,8 @@ from slack_sdk.socket_mode import SocketModeClient # https://github.com/seratch/my-proxy-server -# go build && ./my-proxy-sever -a -proxy_url = "http://user:pass@localhost:9000" +# go build && my-proxy-server -a -u user -p pass/word +proxy_url = "http://user:pass%2Fword@localhost:9000" client = SocketModeClient( app_token=os.environ.get("SLACK_SDK_TEST_SOCKET_MODE_APP_TOKEN"), diff --git a/slack_sdk/socket_mode/builtin/internals.py b/slack_sdk/socket_mode/builtin/internals.py index 25c69360b..44b4a9a08 100644 --- a/slack_sdk/socket_mode/builtin/internals.py +++ b/slack_sdk/socket_mode/builtin/internals.py @@ -12,7 +12,7 @@ from logging import Logger from threading import Lock from typing import Tuple, Optional, Union, List, Callable, Dict -from urllib.parse import urlparse +from urllib.parse import urlparse, unquote from .frame_header import FrameHeader @@ -59,7 +59,9 @@ def _establish_new_socket_connection( message = [f"CONNECT {server_hostname}:{server_port} HTTP/1.0"] if parsed_proxy.username is not None and parsed_proxy.password is not None: # In the case where the proxy is "http://{username}:{password}@{hostname}:{port}" - raw_value = f"{parsed_proxy.username}:{parsed_proxy.password}" + raw_value = ( + f"{unquote(parsed_proxy.username)}:{unquote(parsed_proxy.password)}" + ) auth = b64encode(raw_value.encode("utf-8")).decode("ascii") message.append(f"Proxy-Authorization: Basic {auth}") if proxy_headers is not None: