Skip to content

Official Crawl4AI Cloud: a hosted web scraping, extraction, and search API for AI agents. Free API key, 1,000 credits a month, no card. Fully open source: this repo is the Apache-2.0 crawler that powers it, and you can self-host it.

Decode percent-encoded credentials in ProxyConfig.from_string

omarbounawarapy8b3a75da5fbc
diff --git a/crawl4ai/async_configs.py b/crawl4ai/async_configs.py
index e76cae18..cc1efdb8 100644
--- a/crawl4ai/async_configs.py
+++ b/crawl4ai/async_configs.py
@@ -3,6 +3,7 @@ import functools
import importlib
import os
import warnings
+from urllib.parse import unquote
import requests
from .config import (
DEFAULT_PROVIDER,
@@ -711,8 +712,8 @@ class ProxyConfig:
username, password = credentials.split(":", 1)
return ProxyConfig(
server=f"{protocol}://{server_part}",
- username=username,
- password=password,
+ username=unquote(username),
+ password=unquote(password),
)
# URL without credentials (keep scheme)
if "://" in s and "@" not in s:
diff --git a/tests/proxy/test_http_proxy_url_encoding.py b/tests/proxy/test_http_proxy_url_encoding.py
index e6d75d97..9e7515a1 100644
--- a/tests/proxy/test_http_proxy_url_encoding.py
+++ b/tests/proxy/test_http_proxy_url_encoding.py
@@ -16,3 +16,12 @@ def test_proxy_url_roundtrips_credentials(password):
assert url.port == 8080
assert url.user == "us:er"
assert url.password == password
+
+
+def test_encoded_proxy_string_is_sent_once_encoded():
+ strategy = AsyncHTTPCrawlerStrategy()
+ config = ProxyConfig.from_string("http://user:p%40ss@host:8080")
+ assert config.password == "p@ss"
+ url = URL(strategy._format_proxy_url(config))
+ assert url.user == "user"
+ assert url.password == "p@ss"