diff --git a/rhodecode/lib/vcs/nodes.py b/rhodecode/lib/vcs/nodes.py index 2ee9b24d..b5842869 100644 --- a/rhodecode/lib/vcs/nodes.py +++ b/rhodecode/lib/vcs/nodes.py @@ -114,7 +114,8 @@ class Node(object): only. Moreover, every single node is identified by the ``path`` attribute, so it cannot end with slash, too. Otherwise, path could lead to mistakes. """ - + RTLO_MARKER = u"\u202E" # RTLO marker allows swapping text, and certain + # security attacks could be used with this commit = None def __init__(self, path, kind): @@ -148,6 +149,20 @@ class Node(object): def unicode_path(self): return safe_unicode(self.path) + @LazyProperty + def has_rtlo(self): + """Detects if a path has right-to-left-override marker""" + return self.RTLO_MARKER in self.unicode_path + + @LazyProperty + def unicode_path_safe(self): + """ + Special SAFE representation of path without the right-to-left-override. + This should be only used for "showing" the file, cannot be used for any + urls etc. + """ + return safe_unicode(self.path).replace(self.RTLO_MARKER, '') + @LazyProperty def dir_path(self): """ diff --git a/rhodecode/templates/files/files_source.mako b/rhodecode/templates/files/files_source.mako index 11c2691f..1fe3f19a 100644 --- a/rhodecode/templates/files/files_source.mako +++ b/rhodecode/templates/files/files_source.mako @@ -6,7 +6,7 @@ - ${c.file} + ${c.file.unicode_path_safe} % if c.lf_node: