[Bug]: normalize_url lowercases the userinfo in a URL, so credentials in a link are rewritten
维护者通常 1 天内回复
评估
调研方向
Read the three normalizers named in the issue: normalize_url, normalize_url_for_deep_crawl, and efficient_normalize_url_for_deep_crawl. Check how each handles parsed.netloc and add regression coverage for preserved userinfo casing and lowercase hostnames. The issue says the author has a patch and six tests ready, and linked PR #2530 is open.
由索引模型根据 Issue 内容生成。
描述
Describe the bug
normalize_url, normalize_url_for_deep_crawl and efficient_normalize_url_for_deep_crawl all lowercase the whole netloc:
netloc = parsed.netloc.lower()
netloc also carries the user:password@ part of a URL. A hostname is case-insensitive, so lowering it is right; credentials are not, so the same call silently rewrites them. The comment on the efficient normalizer even says what was intended — # 1. Lowercase hostname.
Steps to Reproduce
from crawl4ai.utils import normalize_url, normalize_url_for_deep_crawl
base = "https://example.com/dir/page"
print(normalize_url("https://User:[email protected]/path", base))
print(normalize_url_for_deep_crawl("https://User:[email protected]/path", base))
Actual:
https://user:[email protected]/path
https://user:[email protected]/path
Expected:
https://User:[email protected]/path
https://User:[email protected]/path
Why it matters
quick_extract_links resolves every <a href> through normalize_url_for_deep_crawl, so any link carrying credentials in its URL is rewritten before the crawl follows it. A page that links to https://user:SecRet@host/ is then fetched with user:secret, and the server answers 401 — or, worse, authenticates as a different account on systems where the userinfo is an identifier rather than a password. The same happens to URLs assembled by hand and passed to the deep-crawl path.
Environment
crawl4aimainatcae74b2- Python 3.13, Windows
- No browser involved: the three functions are pure string handling
Proposed patch
Lowercase only the host, keeping whatever precedes the @ as written:
def _lowercase_host(netloc: str) -> str:
userinfo, separator, hostport = netloc.rpartition('@')
return f"{userinfo}{separator}{hostport.lower()}"
rpartition keeps a %40-encoded @ inside the password intact, since urlparse leaves it encoded in the netloc. Used at the three call sites, the diff is one line each.
Behaviour for URLs without userinfo is unchanged, including the port: Example.COM:8080 still becomes example.com:8080.
I have the patch and six regression tests ready (userinfo casing, host-only casing, userinfo with port, encoded @ in the password, and the two deep-crawl normalizers) and will open the PR against this issue.
- 主要语言
- Python
- 星标
- 87.2k
- 派生
- 9.1k
- 平均合并
- 1 天 6 小时
- 30 天内合并 PR
- 25
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
unclecode/crawl4ai 的其他 Issue
-
BUG: UserAgentGenerator.generate ignores browser_type and returns a random browser stack可能已有人在做 @HhH666-ux 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
[Bug]: Hardened docker-compose (read_only) keeps full Chromium from starting: crashpad needs a writable ~/.config可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭🐞 Bug 📌 Root caused
难度 2/5 1-3 小时 新手友好度 70/100
unclecode/crawl4ai#2494 · 1 条评论 ·
维护者通常 1 天内回复
-
⚙ Done ✨ Enhancement
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 1 天内回复
-
⚙ Done 🐞 Bug 📌 Root caused
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
[Bug]: PDF images saved with save_images_locally=True come back with an empty src in result.media未关闭⚙ Done 🐞 Bug
难度 2/5 1-3 小时 新手友好度 78/100
unclecode/crawl4ai#2469 · 1 条评论 ·
维护者通常 1 天内回复
查看 unclecode/crawl4ai 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 73/100
Netcracker/qubership-ai-packages#266 ·
维护者通常 1 天内回复
-
PROCESSED_DATA_FOLDER: strip whitespace and treat empty as unset可能已有人在做 @TorecLuik 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
NL-BioImaging/BIOMERO.importer#63 ·
维护者通常 1 天内回复
-
MLX training-complete chat/merge suggestions omit --backend mlx可能已有人在做 @vaputa 今天认领。 未关闭needs-triage
难度 2/5 1-3 小时 新手友好度 76/100
MakazhanAlpamys/Soup#2913 · 1 条评论 ·
维护者通常 1 天内回复
-
area:security effort:S priority:P3 status:needs-triage type:chore
难度 2/5 1-3 小时 新手友好度 78/100
randomparity/kdive#3657 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
aws/mcp-proxy-for-aws#476 ·
维护者通常 1 天内回复