diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index 988ca86bf..9829bdd03 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "2.32.24", + "version": "2.32.25", "bin": "bin/hydrooj.js", "main": "src/loader", "module": "src/loader", diff --git a/packages/hydrooj/src/handler/contest.ts b/packages/hydrooj/src/handler/contest.ts index 0feb46392..1193d4e90 100644 --- a/packages/hydrooj/src/handler/contest.ts +++ b/packages/hydrooj/src/handler/contest.ts @@ -327,7 +327,7 @@ export class ContestProblemFileDownloadHandler extends ContestProblemHandler { if (shouldProxy && file.size! < 32 * 1024 * 1024) { this.response.body = await storage.get(target); this.response.type = file['Content-Type'] || type; - if (!noDisposition) this.response.addHeader('Content-Disposition', `attachment; filename=${filename}`); + this.response.disposition = `attachment; filename=${encodeURIComponent(filename)}`; } else { this.response.redirect = await storage.signDownloadLink( target, noDisposition ? undefined : filename, false, 'user', diff --git a/packages/hydrooj/src/handler/homework.ts b/packages/hydrooj/src/handler/homework.ts index ed2c131fa..ce43a4337 100644 --- a/packages/hydrooj/src/handler/homework.ts +++ b/packages/hydrooj/src/handler/homework.ts @@ -191,7 +191,7 @@ export class HomeworkProblemFileDownloadHandler extends HomeworkDetailProblemHan if (shouldProxy && file.size! < 32 * 1024 * 1024) { this.response.body = await storage.get(target); this.response.type = file['Content-Type'] || type; - if (!noDisposition) this.response.addHeader('Content-Disposition', `attachment; filename=${filename}`); + this.response.disposition = `attachment; filename=${encodeURIComponent(filename)}`; } else { this.response.redirect = await storage.signDownloadLink( target, noDisposition ? undefined : filename, false, 'user', diff --git a/packages/hydrooj/src/handler/misc.ts b/packages/hydrooj/src/handler/misc.ts index 38e07d494..128804536 100644 --- a/packages/hydrooj/src/handler/misc.ts +++ b/packages/hydrooj/src/handler/misc.ts @@ -118,7 +118,7 @@ export class FSDownloadHandler extends Handler { if (shouldProxy && file.size! < 32 * 1024 * 1024) { this.response.body = await storage.get(target); this.response.type = file['Content-Type'] || type; - if (!noDisposition) this.response.addHeader('Content-Disposition', `attachment; filename=${filename}`); + this.response.disposition = `attachment; filename=${encodeURIComponent(filename)}`; } else { this.response.redirect = await storage.signDownloadLink( target, noDisposition ? undefined : filename, false, 'user', diff --git a/packages/hydrooj/src/handler/problem.ts b/packages/hydrooj/src/handler/problem.ts index 94ea1083a..eea0d7b3e 100644 --- a/packages/hydrooj/src/handler/problem.ts +++ b/packages/hydrooj/src/handler/problem.ts @@ -424,7 +424,7 @@ export class ProblemFileDownloadHandler extends ProblemDetailHandler { if (shouldProxy && file.size! < 32 * 1024 * 1024) { this.response.body = await storage.get(target); this.response.type = file['Content-Type'] || fileType; - if (!noDisposition) this.response.addHeader('Content-Disposition', `attachment; filename=${filename}`); + this.response.disposition = `attachment; filename=${encodeURIComponent(filename)}`; } else { this.response.redirect = await storage.signDownloadLink( target, noDisposition ? undefined : filename, false, 'user',