[Bug]: normalize_url lowercases the userinfo in a URL, so credentials in a link are rewritten
Les mainteneurs répondent en général sous 1 jour
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 20/100
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- Python
- Étoiles
- 87.2k
- Forks
- 9.1k
- Merge moyen
- 1 j 6 h
- PR mergées (30 j)
- 25
Préparer son environnement
- Fournit un Dockerfile ou un fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de unclecode/crawl4ai
-
BUG: UserAgentGenerator.generate ignores browser_type and returns a random browser stackPeut-être pris @HhH666-ux l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
Les mainteneurs répondent en général sous 1 jour
-
[Bug]: Hardened docker-compose (read_only) keeps full Chromium from starting: crashpad needs a writable ~/.configPeut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouverte🐞 Bug 📌 Root caused
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
unclecode/crawl4ai#2494 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
[Feature]: Crawl4aiDockerClient has no public option for the API token the 0.9 server requiresOuverte⚙ Done ✨ Enhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 77/100
Les mainteneurs répondent en général sous 1 jour
-
⚙ Done 🐞 Bug 📌 Root caused
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
[Bug]: PDF images saved with save_images_locally=True come back with an empty src in result.mediaOuverte⚙ Done 🐞 Bug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
unclecode/crawl4ai#2469 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de unclecode/crawl4ai
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 73/100
Netcracker/qubership-ai-packages#266 ·
Les mainteneurs répondent en général sous 1 jour
-
PROCESSED_DATA_FOLDER: strip whitespace and treat empty as unsetPeut-être pris @TorecLuik l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
NL-BioImaging/BIOMERO.importer#63 ·
Les mainteneurs répondent en général sous 1 jour
-
MLX training-complete chat/merge suggestions omit --backend mlxPeut-être pris @vaputa l’a pris aujourd’hui. Ouverteneeds-triage
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
MakazhanAlpamys/Soup#2913 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
area:security effort:S priority:P3 status:needs-triage type:chore
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
randomparity/kdive#3657 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
aws/mcp-proxy-for-aws#476 ·
Les mainteneurs répondent en général sous 1 jour