diff --git a/kallithea/lib/vcs/backends/git/repository.py b/kallithea/lib/vcs/backends/git/repository.py --- a/kallithea/lib/vcs/backends/git/repository.py +++ b/kallithea/lib/vcs/backends/git/repository.py @@ -192,7 +192,11 @@ class GitRepository(BaseRepository): >>> GitRepository._check_url('git://example.com/\t') Traceback (most recent call last): ... + urllib.error.URLError: + + The failure above will be one of, depending on the level of WhatWG support: urllib.error.URLError: + urllib.error.URLError: """ try: parsed_url = urllib.parse.urlparse(url) @@ -204,6 +208,10 @@ class GitRepository(BaseRepository): if os.path.isabs(url) and os.path.isdir(url): return + unparsed_url = urllib.parse.urlunparse(parsed_url) + if unparsed_url != url: + raise urllib.error.URLError("Invalid url: '%s' normalizes to '%s'" % (url, unparsed_url)) + if parsed_url.scheme == 'git': # Mitigate problems elsewhere with incorrect handling of encoded paths. # Don't trust urllib.parse.unquote but be prepared for more flexible implementations elsewhere.