Merge pull request #26827 from overleaf/mj-zip-download-name

[web] Sanitise project name in zip download

GitOrigin-RevId: 3b22da84002f57e3965c529c673344af04db9128
This commit is contained in:
Mathias Jakobsen
2025-07-08 08:06:26 +00:00
committed by Copybot
parent bd3ef799f3
commit 56232b48a7
3 changed files with 10 additions and 4 deletions
@@ -52,7 +52,7 @@ describe('ProjectDownloadsController', function () {
.stub()
.callsArgWith(1, null, ctx.stream)
ctx.req.params = { Project_id: ctx.project_id }
ctx.project_name = 'project name with accênts'
ctx.project_name = 'project name with accênts and % special characters'
ctx.ProjectGetter.getProject = sinon
.stub()
.callsArgWith(2, null, { name: ctx.project_name })
@@ -95,9 +95,9 @@ describe('ProjectDownloadsController', function () {
.should.equal(true)
})
it('should name the downloaded file after the project', function (ctx) {
it('should name the downloaded file after the project but sanitise special characters', function (ctx) {
ctx.res.headers.should.deep.equal({
'Content-Disposition': `attachment; filename="${ctx.project_name}.zip"`,
'Content-Disposition': `attachment; filename="project_name_with_accênts_and___special_characters.zip"`,
'Content-Type': 'application/zip',
'X-Content-Type-Options': 'nosniff',
})