1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-26 10:50:29 +02:00

fix(server): Do not change file ext case on upload (#2056)

This commit is contained in:
bo0tzz 2023-03-23 15:06:40 +01:00 committed by GitHub
parent c00624f209
commit 8adf1231a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -179,5 +179,18 @@ describe('assetUploadOption', () => {
expect(error).toBeNull(); expect(error).toBeNull();
expect(name.endsWith(mock.userRequest.body.fileExtension)).toBeTruthy(); expect(name.endsWith(mock.userRequest.body.fileExtension)).toBeTruthy();
}); });
it('should not change the casing of the extension', () => {
// Case is deliberately mixed to cover both .upper() and .lower()
const body = { ...mock.userRequest.body, fileExtension: '.JpEg' };
const request = { ...mock.userRequest, body } as Request;
filename(request, mock.file, callback);
expect(callback).toHaveBeenCalled();
const [error, name] = callback.mock.calls[0];
expect(error).toBeNull();
expect(name.endsWith(body.fileExtension)).toBeTruthy();
});
}); });
}); });

View File

@ -97,6 +97,6 @@ function filename(req: Request, file: Express.Multer.File, cb: any) {
return cb(null, sanitize(livePhotoFileName)); return cb(null, sanitize(livePhotoFileName));
} }
const fileName = `${fileNameUUID}${req.body['fileExtension'].toLowerCase()}`; const fileName = `${fileNameUUID}${req.body['fileExtension']}`;
return cb(null, sanitize(fileName)); return cb(null, sanitize(fileName));
} }