1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-12-27 02:16:12 +01:00

Merge pull request #1021 from openSUSE/revert-1020-fix/1018-url-unicode

Revert "Quote unicode characters in URL path"
This commit is contained in:
Marco Strigl 2022-04-01 14:45:38 +02:00 committed by GitHub
commit 34575f8b74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -32,7 +32,7 @@ except ImportError:
distro = None
try:
from urllib.parse import urlsplit, urlunsplit, urlparse, quote, quote_plus, urlencode, unquote
from urllib.parse import urlsplit, urlunsplit, urlparse, quote_plus, urlencode, unquote
from urllib.error import HTTPError, URLError
from urllib.request import pathname2url, install_opener, urlopen
from urllib.request import Request as URLRequest
@ -41,7 +41,7 @@ try:
except ImportError:
#python 2.x
from urlparse import urlsplit, urlunsplit, urlparse
from urllib import pathname2url, quote, quote_plus, urlencode, unquote
from urllib import pathname2url, quote_plus, urlencode, unquote
from urllib2 import HTTPError, URLError, install_opener, urlopen
from urllib2 import Request as URLRequest
from cStringIO import StringIO
@ -3332,22 +3332,7 @@ def makeurl(baseurl, l, query=[]):
query = urlencode(query)
scheme, netloc, path = urlsplit(baseurl)[0:3]
# quote all parts of path in case there's a unicode character
l = [quote(i) for i in l]
joined_path = '/'.join([path] + list(l))
result = urlunsplit((scheme, netloc, joined_path, query, ''))
# check if URL path doesn't contain illegal characters
illegal_chars = ['?']
for illegal_char in illegal_chars:
quoted_illegal_char = quote(illegal_char)
if quoted_illegal_char in joined_path:
msg = "Illegal character '{}' ({}) in URL path: {}"
raise URLError(msg.format(illegal_char, quoted_illegal_char, result))
return result
return urlunsplit((scheme, netloc, '/'.join([path] + list(l)), query, ''))
def http_request(method, url, headers={}, data=None, file=None):