diff --git a/rhodecode/lib/middleware/simplevcs.py b/rhodecode/lib/middleware/simplevcs.py --- a/rhodecode/lib/middleware/simplevcs.py +++ b/rhodecode/lib/middleware/simplevcs.py @@ -48,6 +48,7 @@ from rhodecode.lib.exceptions import (Us from rhodecode.lib.hooks_daemon import prepare_callback_daemon from rhodecode.lib.middleware import appenlight from rhodecode.lib.middleware.utils import scm_app_http +from rhodecode.lib.str_utils import safe_bytes from rhodecode.lib.utils import is_valid_repo, SLUG_RE from rhodecode.lib.utils2 import safe_str, fix_PATH, str2bool, safe_unicode from rhodecode.lib.vcs.conf import settings as vcs_settings @@ -244,7 +245,10 @@ class SimpleVCS(object): if by_id_match: data[1] = by_id_match.repo_name - return safe_str('/'.join(data)) + # Because PEP-3333-WSGI uses bytes-tunneled-in-latin-1 as PATH_INFO + # and we use this data + maybe_new_path = '/'.join(data) + return safe_bytes(maybe_new_path).decode('latin1') def _invalidate_cache(self, repo_name): """ diff --git a/rhodecode/lib/middleware/utils/__init__.py b/rhodecode/lib/middleware/utils/__init__.py --- a/rhodecode/lib/middleware/utils/__init__.py +++ b/rhodecode/lib/middleware/utils/__init__.py @@ -17,3 +17,12 @@ # This program is dual-licensed. If you wish to learn more about the # RhodeCode Enterprise Edition, including its added features, Support services, # and proprietary license terms, please see https://rhodecode.com/licenses/ + +from rhodecode.lib.str_utils import safe_str + + +def get_path_info(environ): + """ + Because PEP-3333-WSGI uses bytes-tunneled-in-latin-1 as PATH_INFO, we use a decoded version here ! + """ + return safe_str(environ['PATH_INFO'].encode('latin1'))