Mercurial > public > mercurial-scm > hg-stable
diff mercurial/util.py @ 30036:3f4e1c033f40
url: fix crash by empty path with #fragments
Before, "#foo" paths made hg crash. We've moved the #fragment parsing at
64fbd0de9773, but we shouldn't set path to None too early. This patch just
removes the "if not path:" block since that's checked a few lines later.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Fri, 30 Sep 2016 21:38:47 +0900 |
parents | 0f6d6fdd3c2a |
children | 42ead5b3aa7b |
line wrap: on
line diff
--- a/mercurial/util.py Wed Sep 28 20:07:32 2016 +0900 +++ b/mercurial/util.py Fri Sep 30 21:38:47 2016 +0900 @@ -2377,6 +2377,22 @@ <url scheme: 'http', host: 'host', path: 'a', query: 'b', fragment: 'c'> >>> url('http://host/a?b#c', parsequery=False, parsefragment=False) <url scheme: 'http', host: 'host', path: 'a?b#c'> + + Empty path: + + >>> url('') + <url path: ''> + >>> url('#a') + <url path: '', fragment: 'a'> + >>> url('http://host/') + <url scheme: 'http', host: 'host', path: ''> + >>> url('http://host/#a') + <url scheme: 'http', host: 'host', path: '', fragment: 'a'> + + Only scheme: + + >>> url('http:') + <url scheme: 'http'> """ _safechars = "!~*'()+" @@ -2393,8 +2409,6 @@ if parsefragment and '#' in path: path, self.fragment = path.split('#', 1) - if not path: - path = None # special case for Windows drive letters and UNC paths if hasdriveletter(path) or path.startswith(r'\\'):