mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-13 07:56:23 +00:00
fix: set upload name utf8 encoding via busboy conf
instead of converting from the default latin1 using Buffer changing busboy config was not possible with express + multer, so i did not notice it's instead possible with hyper-express
This commit is contained in:
parent
db2fd3e4fd
commit
301cf3377d
@ -265,6 +265,8 @@ self.actuallyUpload = async (req, res, user, data = {}) => {
|
||||
|
||||
await req.multipart({
|
||||
// https://github.com/mscdex/busboy/tree/v1.6.0#exports
|
||||
// This would otherwise defaults to latin1
|
||||
defParamCharset: 'utf8',
|
||||
limits: {
|
||||
fileSize: maxSizeBytes,
|
||||
// Maximum number of non-file fields.
|
||||
@ -298,7 +300,8 @@ self.actuallyUpload = async (req, res, user, data = {}) => {
|
||||
const file = {
|
||||
albumid: data.albumid,
|
||||
age: data.age,
|
||||
mimetype: field.mime_type,
|
||||
originalname: field.file.name || '',
|
||||
mimetype: field.mime_type || '',
|
||||
isChunk: req.body.uuid !== undefined &&
|
||||
req.body.chunkindex !== undefined
|
||||
}
|
||||
@ -312,10 +315,6 @@ self.actuallyUpload = async (req, res, user, data = {}) => {
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: Since busboy@1, filenames no longer get automatically parsed as UTF-8, so we force it here
|
||||
file.originalname = field.file.name &&
|
||||
Buffer.from(field.file.name, 'latin1').toString('utf8')
|
||||
|
||||
file.extname = utils.extname(file.originalname)
|
||||
if (self.isExtensionFiltered(file.extname)) {
|
||||
throw new ClientError(`${file.extname ? `${file.extname.substr(1).toUpperCase()} files` : 'Files with no extension'} are not permitted.`)
|
||||
|
Loading…
Reference in New Issue
Block a user