The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(a2a): accept the absolute form localhost. in the no-token Host check
John Paul Soliva53d28d9b8523
diff --git a/plugins/platforms/a2a/security.py b/plugins/platforms/a2a/security.pyindex 03257d39697..4fd3f5dcdce 100644--- a/plugins/platforms/a2a/security.py+++ b/plugins/platforms/a2a/security.py@@ -217,7 +217,8 @@ def is_loopback_host_header(host_header: Optional[str]) -> bool:parts.port # noqa: B018 -- raises ValueError on a malformed portexcept ValueError:return False- return (parts.hostname or "").lower() in _LOOPBACK_HOST_NAMES+ # ``localhost.`` is the absolute form of ``localhost``; a rebound name stays foreign either way.+ return (parts.hostname or "").lower().rstrip(".") in _LOOPBACK_HOST_NAMESdef is_safe_callback_url(url: str, *, localhost_mode: Optional[bool] = None) -> bool:diff --git a/tests/plugins/test_a2a_plugin.py b/tests/plugins/test_a2a_plugin.pyindex 16a98259bb2..08e4ca328f0 100644--- a/tests/plugins/test_a2a_plugin.py+++ b/tests/plugins/test_a2a_plugin.py@@ -1332,7 +1332,9 @@ class TestInboundRoundTrip:(None, True), # urllib's own Host: 127.0.0.1:<port>("localhost", True),("[::1]", True),- ("rebound.example", False), # a page's hostname re-resolved to 127.0.0.1+ ("localhost.", True), # absolute form of localhost+ ("rebound.example", False),+ ("rebound.example.", False), # a page's hostname re-resolved to 127.0.0.1])def test_no_token_listener_serves_only_loopback_host_names(monkeypatch, host, served):"""Without a token the listener trusts the loopback socket; a page on a hostname re-resolved to