[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時間
- マージ済み PR(30日)
- 25
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン🐞 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 日以内に返信