fix: decode multer filename encoding for non-ASCII filenames

This commit is contained in:
ASTERISK Kwon
2026-03-30 20:31:04 +09:00
parent 6444b2b4ce
commit 9f1b0554d6
2 changed files with 2 additions and 0 deletions

View File

@@ -39,6 +39,7 @@ const noteUpload = multer({
filename: (_req, file, cb) => { cb(null, `${uuidv4()}${path.extname(file.originalname)}`) },
}),
limits: { fileSize: MAX_NOTE_FILE_SIZE },
defParamCharset: 'utf8',
fileFilter: (_req, file, cb) => {
const ext = path.extname(file.originalname).toLowerCase();
const BLOCKED = ['.svg', '.html', '.htm', '.xml', '.xhtml', '.js', '.jsx', '.ts', '.exe', '.bat', '.sh', '.cmd', '.msi', '.dll', '.com', '.vbs', '.ps1', '.php'];

View File

@@ -38,6 +38,7 @@ function getAllowedExtensions(): string {
const upload = multer({
storage,
limits: { fileSize: MAX_FILE_SIZE },
defParamCharset: 'utf8',
fileFilter: (_req, file, cb) => {
const ext = path.extname(file.originalname).toLowerCase();
if (BLOCKED_EXTENSIONS.includes(ext) || file.mimetype.includes('svg')) {