Percent-encode commas in download filenames
encodeURI leaves , ; and other reserved characters raw in the RFC 5987
filename* value. A comma in an album title ("Yellow Aster Butte, WA")
makes Chrome see two Content-Disposition headers and fail the download
with ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION. Single-asset
downloads had the same bug for original filenames with a comma.
Both call sites now share attachmentDisposition(), which uses
encodeURIComponent plus the attr-char exclusions ' ( ) *.
This commit is contained in:
@@ -12,6 +12,7 @@ import { isVideoAsset, resolveDownloadEndpoint, resolveImageEndpoint } from '../
|
||||
import { pipeline } from 'stream/promises'
|
||||
import { readableFromWeb } from '../utils/webStream'
|
||||
import { log } from '../utils/log'
|
||||
import { attachmentDisposition } from './download'
|
||||
|
||||
/**
|
||||
* Stream an asset from Immich back to the client.
|
||||
@@ -104,8 +105,7 @@ export async function assetBuffer (req: IncomingShareRequest, res: Response, ass
|
||||
const playbackMime = useVideoPlayback
|
||||
? (data.headers.get('content-type') || '').split(';')[0].trim() || undefined
|
||||
: undefined
|
||||
const filename = encodeURI(getFilename(asset, servedSize, playbackMime))
|
||||
res.setHeader('Content-Disposition', `attachment; filename*=UTF-8''${filename}`)
|
||||
res.setHeader('Content-Disposition', attachmentDisposition(getFilename(asset, servedSize, playbackMime)))
|
||||
}
|
||||
}
|
||||
headerList.forEach(header => {
|
||||
|
||||
Reference in New Issue
Block a user