Explorar o código

fix: encode filenames for assets force download

NGPixel %!s(int64=3) %!d(string=hai) anos
pai
achega
05b4053954
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      server/models/assets.js

+ 1 - 1
server/models/assets.js

@@ -174,7 +174,7 @@ module.exports = class Asset extends Model {
 
       // Force unsafe extensions to download
       if (WIKI.config.uploads.forceDownload && !['.png', '.apng', '.jpg', '.jpeg', '.gif', '.bmp', '.webp', '.svg'].includes(fileInfo.ext)) {
-        res.set('Content-disposition', 'attachment; filename=' + fileInfo.base)
+        res.set('Content-disposition', 'attachment; filename=' + encodeURIComponent(fileInfo.base))
       }
 
       if (await WIKI.models.assets.getAssetFromCache(assetPath, cachePath, res)) {