gh-125926: Fix urllib.parse.urljoin() for base URI with undefined authority (GH-125989)

Although this goes beyond the application of RFC 3986, urljoin()
should support relative base URIs for backward compatibility.
This commit is contained in:
Serhiy Storchaka 2024-11-07 09:09:59 +02:00 committed by GitHub
parent 223d3dc554
commit dbb6e22cb1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 78 additions and 2 deletions

View file

@ -577,9 +577,9 @@ def urljoin(base, url, allow_fragments=True):
if scheme is None:
scheme = bscheme
if scheme != bscheme or scheme not in uses_relative:
if scheme != bscheme or (scheme and scheme not in uses_relative):
return _coerce_result(url)
if scheme in uses_netloc:
if not scheme or scheme in uses_netloc:
if netloc:
return _coerce_result(_urlunsplit(scheme, netloc, path,
query, fragment))