##// END OF EJS Templates
git: disallow odd characters in path of git:// URLs...
Mads Kiilerich -
r8533:a8a51a3b stable
parent child Browse files
Show More
@@ -163,6 +163,18 b' class GitRepository(BaseRepository):'
163 return True
163 return True
164
164
165 if url.startswith('git://'):
165 if url.startswith('git://'):
166 try:
167 _git_colon, _empty, _host, path = url.split('/', 3)
168 except ValueError:
169 raise urllib.error.URLError("Invalid URL: %r" % url)
170 # Mitigate problems elsewhere with incorrect handling of encoded paths.
171 # Don't trust urllib.parse.unquote but be prepared for more flexible implementations elsewhere.
172 # Space is the only allowed whitespace character - directly or % encoded. No other % or \ is allowed.
173 for c in path.replace('%20', ' '):
174 if c in '%\\':
175 raise urllib.error.URLError("Invalid escape character in path: '%s'" % c)
176 if c.isspace() and c != ' ':
177 raise urllib.error.URLError("Invalid whitespace character in path: %r" % c)
166 return True
178 return True
167
179
168 if not url.startswith('http://') and not url.startswith('https://'):
180 if not url.startswith('http://') and not url.startswith('https://'):
General Comments 0
You need to be logged in to leave comments. Login now