Просмотр исходного кода

fix: CodeQl Alert (https://github.com/weseek/growi/security/code-scanning/879, https://github.com/weseek/growi/security/code-scanning/880)

Shun Miyazawa 7 месяцев назад
Родитель
Сommit
73cb738e15
1 измененных файлов с 3 добавлено и 2 удалено
  1. 3 2
      packages/remark-lsx/src/server/routes/list-pages/index.ts

+ 3 - 2
packages/remark-lsx/src/server/routes/list-pages/index.ts

@@ -33,16 +33,17 @@ function addFilterCondition(
   }
 
   const pagePathForRegexp = escapeStringRegexp(addTrailingSlash(pagePath));
+  const sanitizedFilter = escapeStringRegexp(optionsFilter);
 
   let filterPath: RegExp;
   try {
     if (optionsFilter.charAt(0) === '^') {
       // move '^' to the first of path
       filterPath = new RegExp(
-        `^${pagePathForRegexp}${optionsFilter.slice(1, optionsFilter.length)}`,
+        `^${pagePathForRegexp}${optionsFilter.slice(1, sanitizedFilter.length)}`,
       );
     } else {
-      filterPath = new RegExp(`^${pagePathForRegexp}.*${optionsFilter}`);
+      filterPath = new RegExp(`^${pagePathForRegexp}.*${sanitizedFilter}`);
     }
   } catch (err) {
     throw createError(400, err);