Skip to content

Commit

Permalink
fix: encode content disposition file name (#8190)
Browse files Browse the repository at this point in the history
* fix: encide content disposition file name

Signed-off-by: Alexander Onnikov <[email protected]>

* fix: recursively remove temporary directory

Signed-off-by: Alexander Onnikov <[email protected]>

---------

Signed-off-by: Alexander Onnikov <[email protected]>
  • Loading branch information
aonnikov authored Mar 11, 2025
1 parent a89f75a commit 03584ae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion services/datalake/pod-datalake/src/handlers/blob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ export async function handleBlobGet (
res.setHeader('Content-Length', blob.bodyLength.toString())
res.setHeader('Content-Type', blob.contentType ?? '')
res.setHeader('Content-Security-Policy', "default-src 'none';")
res.setHeader('Content-Disposition', filename !== undefined ? `attachment; filename="${filename}"` : 'attachment')
res.setHeader(
'Content-Disposition',
filename !== undefined ? `attachment; filename*=UTF-8''${encodeURIComponent(filename)}"` : 'attachment'
)
res.setHeader('Cache-Control', blob.cacheControl ?? cacheControl)
res.setHeader('Last-Modified', new Date(blob.lastModified).toUTCString())
res.setHeader('ETag', blob.etag)
Expand Down
2 changes: 1 addition & 1 deletion services/datalake/pod-datalake/src/handlers/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export async function handleImageGet (

res.on('finish', () => {
try {
rmSync(tempDir)
rmSync(tempDir, { recursive: true })
} catch (err: any) {
ctx.error('failed to remove temp dir', { workspace, name, error: err })
}
Expand Down

0 comments on commit 03584ae

Please sign in to comment.