fix: correct filename in content-disposition header (#9139)

Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
Alexander Onnikov 2025-05-30 14:06:53 +07:00 committed by GitHub
parent 6f26cf0511
commit 4a9a547bf7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 7 deletions

8
.vscode/launch.json vendored
View File

@ -367,9 +367,7 @@
"METRICS_CONSOLE": "true",
"ACCOUNTS_URL": "http://localhost:3000",
"MONGO_URL": "mongodb://localhost:27017",
"MINIO_ACCESS_KEY": "minioadmin",
"MINIO_SECRET_KEY": "minioadmin",
"MINIO_ENDPOINT": "localhost"
"STORAGE_CONFIG": "datalake|http://localhost:4030"
},
"runtimeVersion": "20",
"runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
@ -763,8 +761,8 @@
"env": {
"PORT": "4030",
"SECRET": "secret",
"DB_URL": "",
"BUCKETS": "",
"DB_URL": "postgresql://root@localhost:26257/defaultdb?sslmode=disable",
"BUCKETS": "blobs,eu|http://localhost:9000?accessKey=minioadmin&secretKey=minioadmin",
"ACCOUNTS_URL": "http://localhost:3000",
"STATS_URL": "http://huly.local:4900",
"STREAM_URL": "http://huly.local:1080/recording"

View File

@ -70,7 +70,7 @@ export async function handleBlobGet (
res.setHeader('Content-Security-Policy', "default-src 'none';")
res.setHeader(
'Content-Disposition',
filename !== undefined ? `attachment; filename*=UTF-8''${encodeURIComponent(filename)}"` : 'attachment'
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())
@ -122,7 +122,10 @@ export async function handleBlobHead (
res.setHeader('Content-Length', head.size.toString())
res.setHeader('Content-Type', head.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', head.cacheControl ?? cacheControl)
res.setHeader('Last-Modified', new Date(head.lastModified).toUTCString())
res.setHeader('ETag', wrapETag(head.etag))