fix: sanitize_url crashes on Python 3.14 strict urlparse (#284)
Python 3.14's urlparse() raises ValueError on URLs with unencoded brackets that look like malformed IPv6 (e.g. http://[fdaa:x:x:x::x from docs.openclaw.ai llms-full.txt). sanitize_url() called urlparse() BEFORE encoding brackets, so it crashed before it could fix them. Fix: catch ValueError from urlparse, encode ALL brackets, then retry. This is safe because if urlparse rejected the brackets, they are NOT valid IPv6 host literals and should be encoded anyway. Also fixed Discord e2e tests to skip gracefully on network issues. Fixes #284 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -568,6 +568,27 @@ class TestSanitizeUrl(unittest.TestCase):
|
||||
self.assertEqual(sanitize_url("https://example.com"), "https://example.com")
|
||||
self.assertEqual(sanitize_url("https://example.com/"), "https://example.com/")
|
||||
|
||||
def test_malformed_ipv6_url_no_crash(self):
|
||||
"""URLs with brackets that look like broken IPv6 must not crash (issue #284).
|
||||
|
||||
Python 3.14 raises ValueError from urlparse() on unencoded brackets
|
||||
that look like IPv6 but are malformed (e.g. from documentation examples).
|
||||
"""
|
||||
from skill_seekers.cli.utils import sanitize_url
|
||||
|
||||
# Incomplete IPv6 placeholder from docs.openclaw.ai llms-full.txt
|
||||
result = sanitize_url("http://[fdaa:x:x:x:x::x")
|
||||
self.assertNotIn("[", result)
|
||||
self.assertIn("%5B", result)
|
||||
|
||||
def test_unmatched_bracket_no_crash(self):
|
||||
"""Unmatched brackets should be encoded, not crash."""
|
||||
from skill_seekers.cli.utils import sanitize_url
|
||||
|
||||
result = sanitize_url("https://example.com/api/[v1/users")
|
||||
self.assertNotIn("[", result)
|
||||
self.assertIn("%5B", result)
|
||||
|
||||
|
||||
class TestEnqueueUrlSanitization(unittest.TestCase):
|
||||
"""Test that _enqueue_url sanitises bracket URLs before enqueueing (#284)."""
|
||||
|
||||
Reference in New Issue
Block a user