diff --git a/seahub/templates/repo.html b/seahub/templates/repo.html
index 42db22169f..824ad49258 100644
--- a/seahub/templates/repo.html
+++ b/seahub/templates/repo.html
@@ -1392,7 +1392,7 @@ function sortDirent() {
var loading_icon = '
';
// cur_path: will be updated after reqDirdata
-var cur_path = "{{ path|safe }}"; {# safe is for ''', '&' included in path #}
+var cur_path = "{{ path|escapejs}}";
// '.dir-link' click handler
function dirlinkClick() {