From cc1a767f9953a1407615bc9ad89cde1980abf865 Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Tue, 16 May 2023 13:19:59 +0100 Subject: [PATCH] Allow all Unicode "letter" characters in PDF filename (#13071) GitOrigin-RevId: 030d7326b33525a34bccff26e12103e9a8e1a3f3 --- services/web/app/src/Features/Compile/CompileController.js | 4 +--- services/web/test/unit/src/Compile/CompileControllerTests.js | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/services/web/app/src/Features/Compile/CompileController.js b/services/web/app/src/Features/Compile/CompileController.js index 0885e91df4..1b8bc1aeb0 100644 --- a/services/web/app/src/Features/Compile/CompileController.js +++ b/services/web/app/src/Features/Compile/CompileController.js @@ -371,9 +371,7 @@ module.exports = CompileController = { }, _getSafeProjectName(project) { - const wordRegExp = /\W/g - const safeProjectName = project.name.replace(wordRegExp, '_') - return safeProjectName + return project.name.replace(/\P{L}/gu, '_') }, deleteAuxFiles(req, res, next) { diff --git a/services/web/test/unit/src/Compile/CompileControllerTests.js b/services/web/test/unit/src/Compile/CompileControllerTests.js index 22d9c032b2..f21e7d9520 100644 --- a/services/web/test/unit/src/Compile/CompileControllerTests.js +++ b/services/web/test/unit/src/Compile/CompileControllerTests.js @@ -356,7 +356,7 @@ describe('CompileController', function () { this.req.params = { Project_id: this.projectId } this.req.query = { pdfng: true } - this.project = { name: 'test namè' } + this.project = { name: 'test namè;' } this.ProjectGetter.getProject = sinon .stub() .callsArgWith(2, null, this.project) @@ -380,7 +380,7 @@ describe('CompileController', function () { it('should set the content-disposition header with a safe version of the project name', function () { this.res.setContentDisposition.should.be.calledWith('inline', { - filename: 'test_nam_.pdf', + filename: 'test_namè_.pdf', }) })