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:
committed by
Copybot
parent
bd3ef799f3
commit
56232b48a7
@@ -347,6 +347,7 @@ const _CompileController = {
|
||||
}
|
||||
},
|
||||
|
||||
// Keep in sync with the logic for zip files in ProjectDownloadsController
|
||||
_getSafeProjectName(project) {
|
||||
return project.name.replace(/[^\p{L}\p{Nd}]/gu, '_')
|
||||
},
|
||||
|
||||
@@ -18,6 +18,11 @@ import { prepareZipAttachment } from '../../infrastructure/Response.js'
|
||||
|
||||
let ProjectDownloadsController
|
||||
|
||||
// Keep in sync with the logic for PDF files in CompileController
|
||||
function getSafeProjectName(project) {
|
||||
return project.name.replace(/[^\p{L}\p{Nd}]/gu, '_')
|
||||
}
|
||||
|
||||
export default ProjectDownloadsController = {
|
||||
downloadProject(req, res, next) {
|
||||
const projectId = req.params.Project_id
|
||||
@@ -41,7 +46,7 @@ export default ProjectDownloadsController = {
|
||||
if (error != null) {
|
||||
return next(error)
|
||||
}
|
||||
prepareZipAttachment(res, `${project.name}.zip`)
|
||||
prepareZipAttachment(res, `${getSafeProjectName(project)}.zip`)
|
||||
return stream.pipe(res)
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user