fix: validate self-host route URLs consistently

This commit is contained in:
Valerio 2026-05-04 14:30:06 +02:00
parent eede2f6953
commit 1c9def2fde
8 changed files with 26 additions and 10 deletions

View file

@ -43,10 +43,11 @@ pub async fn extract(
"either `schema` or `prompt` is required",
));
}
let url = webclaw_fetch::url_security::validate_public_http_url(&req.url).await?;
// Fetch + extract first so we feed the LLM clean markdown instead of
// raw HTML. Cheaper tokens, better signal.
let extraction = state.fetch().fetch_and_extract(&req.url).await?;
let extraction = state.fetch().fetch_and_extract(url.as_str()).await?;
let content = if extraction.content.markdown.trim().is_empty() {
extraction.content.plain_text.clone()
} else {