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

Merge pull request #632 from weseek/fix/631-regex-for-tempalte-search

fix #631 escape regular expression special characters in the path
Yuki Takei 7 лет назад
Родитель
Сommit
4da423f7d5
1 измененных файлов с 1 добавлено и 1 удалено
  1. 1 1
      src/server/models/page.js

+ 1 - 1
src/server/models/page.js

@@ -540,7 +540,7 @@ module.exports = function(crowi) {
     const Page = this;
     const Page = this;
     const templatePath = cutOffLastSlash(path);
     const templatePath = cutOffLastSlash(path);
     const pathList = generatePathsOnTree(templatePath, []);
     const pathList = generatePathsOnTree(templatePath, []);
-    const regexpList = pathList.map(path => new RegExp(`^${path}/_{1,2}template$`));
+    const regexpList = pathList.map(path => new RegExp(`^${escapeStringRegexp(path)}/_{1,2}template$`));
 
 
     return Page
     return Page
       .find({path: {$in: regexpList}})
       .find({path: {$in: regexpList}})