mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-07-21 10:15:47 +00:00
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:
co-authored by
chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
parent
ac5fd46281
commit
16a77cb780
@@ -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 ""
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user