path-permissions: Introduced a _get_f_path_unchecked method, which can be used by redirects, which don't have to create a template context

This commit is contained in:
Sandu Turcan 2018-02-19 09:48:47 -05:00
parent cfbe15353a
commit c3183aae9a
2 changed files with 10 additions and 4 deletions

View file

@ -229,13 +229,19 @@ class RepoAppView(BaseAppView):
return c
def _get_f_path(self, matchdict, default=None):
def _get_f_path_unchecked(self, matchdict, default=None):
"""
Should only be used by redirects, everything else should call _get_f_path
"""
f_path = matchdict.get('f_path')
if f_path:
# fix for multiple initial slashes that causes errors for GIT
return self.path_filter.assert_path_permissions(f_path.lstrip('/'))
return f_path.lstrip('/')
return self.path_filter.assert_path_permissions(default)
return default
def _get_f_path(self, matchdict, default=None):
return self.path_filter.assert_path_permissions(self._get_f_path_unchecked(matchdict, default))
class PathFilter(object):

View file

@ -462,7 +462,7 @@ class RepoFilesView(RepoAppView):
"""
Kept only to make OLD links work
"""
f_path = self._get_f_path(self.request.matchdict)
f_path = self._get_f_path_unchecked(self.request.matchdict)
diff1 = self.request.GET.get('diff1', '')
diff2 = self.request.GET.get('diff2', '')