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) {
|
uploadProject(req, res, next) {
|
||||||
const timer = new metrics.Timer('project-upload')
|
const timer = new metrics.Timer('project-upload')
|
||||||
const userId = SessionManager.getLoggedInUserId(req.session)
|
const userId = SessionManager.getLoggedInUserId(req.session)
|
||||||
const { originalname, path } = req.file
|
const { path } = req.file
|
||||||
const name = Path.basename(originalname, '.zip')
|
const name = Path.basename(req.body.name, '.zip')
|
||||||
return ProjectUploadManager.createProjectFromZipArchive(
|
return ProjectUploadManager.createProjectFromZipArchive(
|
||||||
userId,
|
userId,
|
||||||
name,
|
name,
|
||||||
|
@ -73,7 +73,7 @@ module.exports = ProjectUploadController = {
|
||||||
|
|
||||||
uploadFile(req, res, next) {
|
uploadFile(req, res, next) {
|
||||||
const timer = new metrics.Timer('file-upload')
|
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 path = req.file != null ? req.file.path : undefined
|
||||||
const projectId = req.params.Project_id
|
const projectId = req.params.Project_id
|
||||||
const { folder_id: folderId } = req.query
|
const { folder_id: folderId } = req.query
|
||||||
|
|
|
@ -189,6 +189,7 @@ describe('ProjectDuplicateNames', function () {
|
||||||
qqfilename: 'frog.jpg',
|
qqfilename: 'frog.jpg',
|
||||||
},
|
},
|
||||||
formData: {
|
formData: {
|
||||||
|
name: 'frog.jpg',
|
||||||
qqfile: {
|
qqfile: {
|
||||||
value: fs.createReadStream(
|
value: fs.createReadStream(
|
||||||
Path.join(__dirname, '/../files/1pixel.png')
|
Path.join(__dirname, '/../files/1pixel.png')
|
||||||
|
|
|
@ -105,6 +105,7 @@ describe('ProjectStructureChanges', function () {
|
||||||
{
|
{
|
||||||
uri: 'project/new/upload',
|
uri: 'project/new/upload',
|
||||||
formData: {
|
formData: {
|
||||||
|
name: zipFilename,
|
||||||
qqfile: zipFile,
|
qqfile: zipFile,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -492,6 +492,7 @@ class User {
|
||||||
folder_id: String(folderId),
|
folder_id: String(folderId),
|
||||||
},
|
},
|
||||||
formData: {
|
formData: {
|
||||||
|
name,
|
||||||
qqfile: {
|
qqfile: {
|
||||||
value: imageFile,
|
value: imageFile,
|
||||||
options: {
|
options: {
|
||||||
|
|
|
@ -61,7 +61,9 @@ describe('ProjectUploadController', function () {
|
||||||
this.name = 'filename.zip'
|
this.name = 'filename.zip'
|
||||||
this.req.file = {
|
this.req.file = {
|
||||||
path: this.path,
|
path: this.path,
|
||||||
originalname: this.name,
|
}
|
||||||
|
this.req.body = {
|
||||||
|
name: this.name,
|
||||||
}
|
}
|
||||||
this.req.session = {
|
this.req.session = {
|
||||||
user: {
|
user: {
|
||||||
|
@ -165,7 +167,9 @@ describe('ProjectUploadController', function () {
|
||||||
this.name = 'filename.png'
|
this.name = 'filename.png'
|
||||||
this.req.file = {
|
this.req.file = {
|
||||||
path: this.path,
|
path: this.path,
|
||||||
originalname: this.name,
|
}
|
||||||
|
this.req.body = {
|
||||||
|
name: this.name,
|
||||||
}
|
}
|
||||||
this.req.session = {
|
this.req.session = {
|
||||||
user: {
|
user: {
|
||||||
|
@ -257,7 +261,7 @@ describe('ProjectUploadController', function () {
|
||||||
|
|
||||||
describe('with an invalid filename', function () {
|
describe('with an invalid filename', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.req.file.originalname = ''
|
this.req.body.name = ''
|
||||||
return this.ProjectUploadController.uploadFile(this.req, this.res)
|
return this.ProjectUploadController.uploadFile(this.req, this.res)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue