Browse Source

fix: asset path traversal on windows

NGPixel 3 năm trước cách đây
mục cha
commit
414033de9d
1 tập tin đã thay đổi với 2 bổ sung0 xóa
  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)