瀏覽代碼

fix: asset path traversal on windows

NGPixel 3 年之前
父節點
當前提交
414033de9d
共有 1 個文件被更改,包括 2 次插入0 次删除
  1. 2 0
      server/helpers/page.js

+ 2 - 0
server/helpers/page.js

@@ -35,6 +35,8 @@ module.exports = {
     rawPath = rawPath.replace(unsafeCharsRegex, '')
     if (rawPath === '') { rawPath = 'home' }
 
+    rawPath = rawPath.replaceAll('\\', '').replaceAll('//', '').replaceAll(/\.\.+/ig, '')
+
     // Extract Info
     let pathParts = _.filter(_.split(rawPath, '/'), p => {
       p = _.trim(p)