#140 allow non-ASCII characters in downloaded zip filename

This commit is contained in:
Alan Grainger
2025-10-10 16:27:33 +08:00
parent 1191fa84ea
commit 18bf03239f
3 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* From https://github.com/parshap/node-sanitize-filename
* From https://www.npmjs.com/package/sanitize-filename
*
* Replaces characters in strings that are illegal/unsafe for filenames.
* Unsafe characters are either removed or replaced by a substitute set
+3 -2
View File
@@ -171,8 +171,9 @@ class Render {
*/
async downloadAll (res: Response, share: SharedLink) {
res.setHeader('Content-Type', 'application/zip')
const title = (sanitize(this.title(share)) || 'photos') + '.zip'
res.setHeader('Content-Disposition', `attachment; filename="${title}"`)
let filename = (sanitize(this.title(share)) || 'photos') + '.zip'
filename = encodeURI(filename)
res.setHeader('Content-Disposition', `attachment; filename*=UTF-8''${filename}`)
const archive = archiver('zip', { zlib: { level: 6 } })
archive.pipe(res)
for (const asset of share.assets) {