Explorar o código

fix: asset path traversal on windows

NGPixel %!s(int64=3) %!d(string=hai) anos
pai
achega
414033de9d
Modificáronse 1 ficheiros con 2 adicións e 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, '')
     if (rawPath === '') { rawPath = 'home' }
 
+    rawPath = rawPath.replaceAll('\\', '').replaceAll('//', '').replaceAll(/\.\.+/ig, '')
+
     // Extract Info
     let pathParts = _.filter(_.split(rawPath, '/'), p => {
       p = _.trim(p)