core-app: use a consistent pep-3333 compatible PATH_INFO extraction

This commit is contained in:
RhodeCode Admin 2023-05-11 12:28:41 +02:00
parent decb5f5681
commit 9740247ef1
2 changed files with 14 additions and 1 deletions

View file

@ -48,6 +48,7 @@ from rhodecode.lib.exceptions import (UserCreationError, NotAllowedToCreateUserE
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):
"""

View file

@ -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'))