requarks / wiki

Wiki.js | A modern and powerful wiki app built on Node.js

Home Page:https://js.wiki

Repository from Github https://github.comrequarks/wikiRepository from Github https://github.comrequarks/wiki

error: Invalid character in header content ["Content-disposition"]

0v3rd0z3d opened this issue · comments

Discussed in #4929

Originally posted by 0v3rd0z3d January 24, 2022
image
image
Acquired an"internal server error" while trying to open assets. Names are in Russian characters.
Not having this error with filenames in english characters.
Versions of wikijs with this issue: 2.5.268, 2.5.272
Not having this error in version: 2.5.201
Thank you in advance!

Same issue here. But file name is in Traditional Chinese.

Same issue here.

"ü" (HTML ü // ASCII Code 129) Doesn't work.

"ä" (HTML ä // ASCII Code 132) works 😕

similarly :(

This should fix the issue.

wiki/server/models/assets.js

--- assets.js.old       2022-04-02 04:58:00.161301315 +0800
+++ assets.js   2022-04-02 04:57:28.598543664 +0800
@@ -174,7 +174,7 @@
 
       // 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)) {

@dcfreedom Please submit a PR with the fix.