Skip to content

Commit 7e2dfd6

Browse files
committed
refactor(utils): adopt upstream address classification into UrlValidator
During the rebase onto main, fold the improved address classification from push_url_validator into the composable stack: unwrap IPv4-mapped IPv6 addresses before checks and use 'not is_global' so RFC 6598 shared address space (100.64.0.0/10) is rejected as well. The backwards-compatible wrapper stays a thin delegation. Signed-off-by: andy <linux2011@qq.com>
1 parent 785e61d commit 7e2dfd6

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

‎src/a2a/utils/url_validation.py‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,18 @@ def hostname(self) -> str:
5252

5353

5454
def _is_non_public(address: UrlAddress) -> bool:
55-
"""Whether an address is not a public unicast destination."""
55+
"""Whether an address is not a public unicast destination.
56+
57+
RFC 6598 shared address space (100.64.0.0/10) is not public:
58+
``ipaddress`` leaves ``is_private`` false for it and ``is_global``
59+
false as well, so ``not is_global`` still rejects it. An IPv4-mapped
60+
IPv6 address is judged as the IPv4 address inside it.
61+
"""
62+
mapped = getattr(address, 'ipv4_mapped', None)
63+
if mapped is not None:
64+
address = mapped
5665
return (
57-
address.is_private
66+
not address.is_global
5867
or address.is_loopback
5968
or address.is_link_local
6069
or address.is_multicast

0 commit comments

Comments
 (0)