fix(serper): ignore malformed image URLs (#4319)

Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
This commit is contained in:
VectorPeak
2026-07-21 08:15:33 +08:00
committed by GitHub
co-authored by chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
parent ac5fd46281
commit 16a77cb780
2 changed files with 9 additions and 1 deletions
@@ -149,7 +149,10 @@ def _safe_public_url(value: object) -> str:
if not isinstance(value, str):
return ""
url = value.strip()
parsed = urlparse(url)
try:
parsed = urlparse(url)
except ValueError:
return ""
if parsed.scheme not in {"http", "https"} or not parsed.netloc or not parsed.hostname:
return ""
+5
View File
@@ -269,6 +269,11 @@ class TestSafePublicUrl:
assert _safe_public_url("http://[::ffff:127.0.0.1]/x.jpg") == ""
def test_malformed_ipv6_url_does_not_raise(self):
from deerflow.community.serper.tools import _safe_public_url
assert _safe_public_url("http://[::1/i.jpg") == ""
def test_non_http_scheme_is_filtered(self):
from deerflow.community.serper.tools import _safe_public_url