# HG changeset patch # User Mads Kiilerich # Date 1496105985 -7200 # Node ID 182f46d62ab4b23f0287f86fe875ad4c170bf068 # Parent 5eb412b5d3651acda98f89bec3da4afac00b81a9 repository: fix crash when forking repositories with unicode names diff -r 5eb412b5d365 -r 182f46d62ab4 kallithea/lib/vcs/backends/git/repository.py --- a/kallithea/lib/vcs/backends/git/repository.py Tue May 30 02:59:45 2017 +0200 +++ b/kallithea/lib/vcs/backends/git/repository.py Tue May 30 02:59:45 2017 +0200 @@ -30,7 +30,7 @@ BranchDoesNotExistError, ChangesetDoesNotExistError, EmptyRepositoryError, RepositoryError, TagAlreadyExistError, TagDoesNotExistError ) -from kallithea.lib.vcs.utils import safe_unicode, makedate, date_fromtimestamp +from kallithea.lib.vcs.utils import safe_str, safe_unicode, makedate, date_fromtimestamp from kallithea.lib.vcs.utils.lazy import LazyProperty from kallithea.lib.vcs.utils.ordered_dict import OrderedDict from kallithea.lib.vcs.utils.paths import abspath, get_user_home @@ -328,7 +328,7 @@ Returns normalized url. If schema is not given, would fall to filesystem (``file:///``) schema. """ - url = str(url) + url = safe_str(url) if url != 'default' and not '://' in url: url = ':///'.join(('file', url)) return url diff -r 5eb412b5d365 -r 182f46d62ab4 kallithea/lib/vcs/backends/hg/repository.py --- a/kallithea/lib/vcs/backends/hg/repository.py Tue May 30 02:59:45 2017 +0200 +++ b/kallithea/lib/vcs/backends/hg/repository.py Tue May 30 02:59:45 2017 +0200 @@ -349,7 +349,7 @@ try: if src_url: - url = str(self._get_url(src_url)) + url = safe_str(self._get_url(src_url)) opts = {} if not update_after_clone: opts.update({'noupdate': True}) @@ -481,7 +481,7 @@ to filesystem (``file:///``) schema. """ - url = str(url) + url = safe_str(url) if url != 'default' and not '://' in url: url = "file:" + urllib.pathname2url(url) return url diff -r 5eb412b5d365 -r 182f46d62ab4 kallithea/tests/functional/test_forks.py --- a/kallithea/tests/functional/test_forks.py Tue May 30 02:59:45 2017 +0200 +++ b/kallithea/tests/functional/test_forks.py Tue May 30 02:59:45 2017 +0200 @@ -161,7 +161,28 @@ fork_repo = Repository.get_by_repo_name(safe_unicode(fork_name)) assert fork_repo - # remove this fork + # fork the fork + fork_name_2 = safe_str(self.REPO_FORK + u'-blåbærgrød') + creation_args = { + 'repo_name': fork_name_2, + 'repo_group': u'-1', + 'fork_parent_id': fork_repo.repo_id, + 'repo_type': self.REPO_TYPE, + 'description': 'unicode repo 2', + 'private': 'False', + 'landing_rev': 'rev:tip', + '_authentication_token': self.authentication_token()} + self.app.post(url(controller='forks', action='fork_create', + repo_name=fork_name), creation_args) + response = self.app.get(url(controller='forks', action='forks', + repo_name=fork_name)) + response.mustcontain( + """%s""" % (urllib.quote(fork_name_2), fork_name_2) + ) + + # remove these forks + response = self.app.post(url('delete_repo', repo_name=fork_name_2), + params={'_authentication_token': self.authentication_token()}) response = self.app.post(url('delete_repo', repo_name=fork_name), params={'_authentication_token': self.authentication_token()})