Fix #140 allow non-English characters in downloaded zip filename

This commit is contained in:
Alan Grainger
2025-10-10 11:50:52 +08:00
parent b7c1be77cf
commit 64368197cb
4 changed files with 53 additions and 4 deletions
+2 -1
View File
@@ -4,6 +4,7 @@ import { Asset, AssetType, ImageSize, IncomingShareRequest, SharedLink } from '.
import { canDownload, getConfigOption } from './functions'
import archiver from 'archiver'
import { respondToInvalidRequest } from './invalidRequestHandler'
import { sanitize } from './includes/sanitize'
class Render {
lgConfig
@@ -170,7 +171,7 @@ class Render {
*/
async downloadAll (res: Response, share: SharedLink) {
res.setHeader('Content-Type', 'application/zip')
const title = this.title(share).replace(/[^\w .-]/g, '') + '.zip'
const title = sanitize(this.title(share)) + '.zip'
res.setHeader('Content-Disposition', `attachment; filename="${title}"`)
const archive = archiver('zip', { zlib: { level: 6 } })
archive.pipe(res)