fix(app): collection fetches addresses with Korean paths and words

The request line is ASCII: other characters and spaces in the path and query go as UTF-8 %HH,
while existing %HH and separators stay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-13 21:49:01 +09:00
parent d0cb540fa0
commit 69f1bf4fa9
3 changed files with 16 additions and 2 deletions

View File

@@ -135,6 +135,10 @@ def _connect(ips: list, port: int, deadline: float) -> socket.socket:
raise
def _ascii(part: str) -> str:
return urllib.parse.quote(part, safe="/%:@!$&'()*+,;=?[]~")
def _get(url: str, deadline: float, dog: _Watchdog):
"""One hop: ("redirect", next url) or ("body", bytes)."""
import http.client
@@ -161,7 +165,9 @@ def _get(url: str, deadline: float, dog: _Watchdog):
else:
conn = http.client.HTTPConnection(p.hostname, port)
conn.sock = sock
path = (p.path or "/") + (f"?{p.query}" if p.query else "")
# The request line is ASCII: other characters (and spaces) go as UTF-8 %HH; existing %HH
# and the reserved separators stay as they are.
path = _ascii(p.path or "/") + (f"?{_ascii(p.query)}" if p.query else "")
conn.request("GET", path, headers={"User-Agent": USER_AGENT, "Accept-Encoding": "identity"})
r = conn.getresponse()
if r.status in (301, 302, 303, 307, 308):