Explorar el Código

fix: asset path traversal on windows

NGPixel hace 3 años
padre
commit
414033de9d
Se han modificado 1 ficheros con 2 adiciones y 0 borrados
  1. 2 0
      server/helpers/page.js

+ 2 - 0
server/helpers/page.js

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