Show More
@@ -25,7 +25,7 b' import shutil' | |||||
25 | import tempfile |
|
25 | import tempfile | |
26 | import collections |
|
26 | import collections | |
27 | import urllib.request, urllib.parse, urllib.error |
|
27 | import urllib.request, urllib.parse, urllib.error | |
28 |
import pathlib |
|
28 | import pathlib | |
29 |
|
29 | |||
30 | from pyramid.httpexceptions import HTTPNotFound, HTTPBadRequest, HTTPFound |
|
30 | from pyramid.httpexceptions import HTTPNotFound, HTTPBadRequest, HTTPFound | |
31 |
|
31 | |||
@@ -43,7 +43,7 b' from rhodecode.lib.exceptions import Non' | |||||
43 | from rhodecode.lib.codeblocks import ( |
|
43 | from rhodecode.lib.codeblocks import ( | |
44 | filenode_as_lines_tokens, filenode_as_annotated_lines_tokens) |
|
44 | filenode_as_lines_tokens, filenode_as_annotated_lines_tokens) | |
45 | from rhodecode.lib.utils2 import ( |
|
45 | from rhodecode.lib.utils2 import ( | |
46 |
convert_line_endings, detect_mode, safe_str, str2bool, safe_int, sha1 |
|
46 | convert_line_endings, detect_mode, safe_str, str2bool, safe_int, sha1) | |
47 | from rhodecode.lib.auth import ( |
|
47 | from rhodecode.lib.auth import ( | |
48 | LoginRequired, HasRepoPermissionAnyDecorator, CSRFRequired) |
|
48 | LoginRequired, HasRepoPermissionAnyDecorator, CSRFRequired) | |
49 | from rhodecode.lib.vcs import path as vcspath |
|
49 | from rhodecode.lib.vcs import path as vcspath | |
@@ -304,10 +304,10 b' class RepoFilesView(RepoAppView):' | |||||
304 | def create_pure_path(self, *parts): |
|
304 | def create_pure_path(self, *parts): | |
305 | # Split paths and sanitize them, removing any ../ etc |
|
305 | # Split paths and sanitize them, removing any ../ etc | |
306 | sanitized_path = [ |
|
306 | sanitized_path = [ | |
307 |
x for x in pathlib |
|
307 | x for x in pathlib.PurePath(*parts).parts | |
308 | if x not in ['.', '..']] |
|
308 | if x not in ['.', '..']] | |
309 |
|
309 | |||
310 |
pure_path = pathlib |
|
310 | pure_path = pathlib.PurePath(*sanitized_path) | |
311 | return pure_path |
|
311 | return pure_path | |
312 |
|
312 | |||
313 | def _is_lf_enabled(self, target_repo): |
|
313 | def _is_lf_enabled(self, target_repo): | |
@@ -676,6 +676,7 b' class RepoFilesView(RepoAppView):' | |||||
676 | # files or dirs |
|
676 | # files or dirs | |
677 | try: |
|
677 | try: | |
678 | c.file = c.commit.get_node(f_path) |
|
678 | c.file = c.commit.get_node(f_path) | |
|
679 | ||||
679 | c.file_author = True |
|
680 | c.file_author = True | |
680 | c.file_tree = '' |
|
681 | c.file_tree = '' | |
681 |
|
682 | |||
@@ -1287,7 +1288,7 b' class RepoFilesView(RepoAppView):' | |||||
1287 |
|
1288 | |||
1288 | root_path = c.file.dir_path |
|
1289 | root_path = c.file.dir_path | |
1289 | pure_path = self.create_pure_path(root_path, filename) |
|
1290 | pure_path = self.create_pure_path(root_path, filename) | |
1290 |
node_path = |
|
1291 | node_path = pure_path.as_posix() | |
1291 |
|
1292 | |||
1292 | default_redirect_url = h.route_path('repo_commit', repo_name=self.db_repo_name, |
|
1293 | default_redirect_url = h.route_path('repo_commit', repo_name=self.db_repo_name, | |
1293 | commit_id=commit_id) |
|
1294 | commit_id=commit_id) | |
@@ -1398,6 +1399,7 b' class RepoFilesView(RepoAppView):' | |||||
1398 | message = r_post.get('message') or c.default_message |
|
1399 | message = r_post.get('message') or c.default_message | |
1399 | filename = r_post.get('filename') |
|
1400 | filename = r_post.get('filename') | |
1400 | unix_mode = 0 |
|
1401 | unix_mode = 0 | |
|
1402 | ||||
1401 | content = convert_line_endings(r_post.get('content', ''), unix_mode) |
|
1403 | content = convert_line_endings(r_post.get('content', ''), unix_mode) | |
1402 |
|
1404 | |||
1403 | if not filename: |
|
1405 | if not filename: | |
@@ -1412,7 +1414,7 b' class RepoFilesView(RepoAppView):' | |||||
1412 |
|
1414 | |||
1413 | root_path = f_path |
|
1415 | root_path = f_path | |
1414 | pure_path = self.create_pure_path(root_path, filename) |
|
1416 | pure_path = self.create_pure_path(root_path, filename) | |
1415 |
node_path = |
|
1417 | node_path = pure_path.as_posix().lstrip('/') | |
1416 |
|
1418 | |||
1417 | author = self._rhodecode_db_user.full_contact |
|
1419 | author = self._rhodecode_db_user.full_contact | |
1418 | nodes = { |
|
1420 | nodes = { | |
@@ -1514,7 +1516,7 b' class RepoFilesView(RepoAppView):' | |||||
1514 |
|
1516 | |||
1515 | root_path = f_path |
|
1517 | root_path = f_path | |
1516 | pure_path = self.create_pure_path(root_path, filename) |
|
1518 | pure_path = self.create_pure_path(root_path, filename) | |
1517 |
node_path = |
|
1519 | node_path = pure_path.as_posix().lstrip('/') | |
1518 |
|
1520 | |||
1519 | nodes[node_path] = { |
|
1521 | nodes[node_path] = { | |
1520 | 'content': content |
|
1522 | 'content': content |
General Comments 0
You need to be logged in to leave comments.
Login now