fix(tools): tighten web fetch URL cleaning

Made-with: Cursor
This commit is contained in:
Xubin Ren
2026-05-01 19:58:19 +08:00
committed by Xubin Ren
parent 5dc96505e8
commit aea5948b11
2 changed files with 22 additions and 6 deletions
+1 -3
View File
@@ -388,9 +388,7 @@ class WebFetchTool(Tool):
max_chars: int | None = None,
**kwargs: Any,
) -> Any:
url = url.strip().strip("`").strip('"').strip("'")
if not (url.startswith("http://") or url.startswith("https://")):
return json.dumps({"error": "Invalid URL after cleaning", "url": url}, ensure_ascii=False)
url = url.strip(" \t\r\n`\"'")
extract_mode = kwargs.pop("extractMode", extract_mode)
max_chars = kwargs.pop("maxChars", max_chars) or self.max_chars
is_valid, error_msg = _validate_url_safe(url)