mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #12654 from overleaf/em-td-upload-filename-encoding
Fix filename encoding of project and file uploads GitOrigin-RevId: e718c8f8f376772ee13c50c82d26848977e16eef
This commit is contained in:
parent
cff54eae78
commit
5b804ceefd
5 changed files with 13 additions and 6 deletions
|
@ -39,8 +39,8 @@ module.exports = ProjectUploadController = {
|
|||
uploadProject(req, res, next) {
|
||||
const timer = new metrics.Timer('project-upload')
|
||||
const userId = SessionManager.getLoggedInUserId(req.session)
|
||||
const { originalname, path } = req.file
|
||||
const name = Path.basename(originalname, '.zip')
|
||||
const { path } = req.file
|
||||
const name = Path.basename(req.body.name, '.zip')
|
||||
return ProjectUploadManager.createProjectFromZipArchive(
|
||||
userId,
|
||||
name,
|
||||
|
@ -73,7 +73,7 @@ module.exports = ProjectUploadController = {
|
|||
|
||||
uploadFile(req, res, next) {
|
||||
const timer = new metrics.Timer('file-upload')
|
||||
const name = req.file != null ? req.file.originalname : undefined
|
||||
const name = req.body.name
|
||||
const path = req.file != null ? req.file.path : undefined
|
||||
const projectId = req.params.Project_id
|
||||
const { folder_id: folderId } = req.query
|
||||
|
|
|
@ -189,6 +189,7 @@ describe('ProjectDuplicateNames', function () {
|
|||
qqfilename: 'frog.jpg',
|
||||
},
|
||||
formData: {
|
||||
name: 'frog.jpg',
|
||||
qqfile: {
|
||||
value: fs.createReadStream(
|
||||
Path.join(__dirname, '/../files/1pixel.png')
|
||||
|
|
|
@ -105,6 +105,7 @@ describe('ProjectStructureChanges', function () {
|
|||
{
|
||||
uri: 'project/new/upload',
|
||||
formData: {
|
||||
name: zipFilename,
|
||||
qqfile: zipFile,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -492,6 +492,7 @@ class User {
|
|||
folder_id: String(folderId),
|
||||
},
|
||||
formData: {
|
||||
name,
|
||||
qqfile: {
|
||||
value: imageFile,
|
||||
options: {
|
||||
|
|
|
@ -61,7 +61,9 @@ describe('ProjectUploadController', function () {
|
|||
this.name = 'filename.zip'
|
||||
this.req.file = {
|
||||
path: this.path,
|
||||
originalname: this.name,
|
||||
}
|
||||
this.req.body = {
|
||||
name: this.name,
|
||||
}
|
||||
this.req.session = {
|
||||
user: {
|
||||
|
@ -165,7 +167,9 @@ describe('ProjectUploadController', function () {
|
|||
this.name = 'filename.png'
|
||||
this.req.file = {
|
||||
path: this.path,
|
||||
originalname: this.name,
|
||||
}
|
||||
this.req.body = {
|
||||
name: this.name,
|
||||
}
|
||||
this.req.session = {
|
||||
user: {
|
||||
|
@ -257,7 +261,7 @@ describe('ProjectUploadController', function () {
|
|||
|
||||
describe('with an invalid filename', function () {
|
||||
beforeEach(function () {
|
||||
this.req.file.originalname = ''
|
||||
this.req.body.name = ''
|
||||
return this.ProjectUploadController.uploadFile(this.req, this.res)
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue