aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js/features/repo-findfile.js
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-02-04 18:30:55 +0800
committerGitHub <noreply@github.com>2023-02-04 10:30:55 +0000
commitea13b23349ef98249deeb9469f6b1444de42abf5 (patch)
tree4fde9c58046a11e5ee4472ad6113584f1aae45f2 /web_src/js/features/repo-findfile.js
parent2741546bed546fbe9792b48119743cfaebfec6bf (diff)
downloadgitea-ea13b23349ef98249deeb9469f6b1444de42abf5.tar.gz
gitea-ea13b23349ef98249deeb9469f6b1444de42abf5.zip
Escape path for the file list (#22741)
Fix #22740
Diffstat (limited to 'web_src/js/features/repo-findfile.js')
-rw-r--r--web_src/js/features/repo-findfile.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/web_src/js/features/repo-findfile.js b/web_src/js/features/repo-findfile.js
index 7b8833e793..f279dfeeb7 100644
--- a/web_src/js/features/repo-findfile.js
+++ b/web_src/js/features/repo-findfile.js
@@ -72,6 +72,10 @@ export function filterRepoFilesWeighted(files, filter) {
return filterResult;
}
+export function escapePath(s) {
+ return s.split('/').map(encodeURIComponent).join('/');
+}
+
function filterRepoFiles(filter) {
const treeLink = $repoFindFileInput.attr('data-url-tree-link');
$repoFindFileTableBody.empty();
@@ -83,7 +87,7 @@ function filterRepoFiles(filter) {
for (const r of filterResult) {
const $row = $(tmplRow);
const $a = $row.find('a');
- $a.attr('href', `${treeLink}/${r.matchResult.join('')}`);
+ $a.attr('href', `${treeLink}/${escapePath(r.matchResult.join(''))}`);
const $octiconFile = $(svg('octicon-file')).addClass('mr-3');
$a.append($octiconFile);
// if the target file path is "abc/xyz", to search "bx", then the matchResult is ['a', 'b', 'c/', 'x', 'yz']