Skip to content

Commit da035fa

Browse files
committed
fix(ramp): sanitize MIME type before embedding in multipart header
1 parent 77f9858 commit da035fa

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

  • apps/sim/app/api/tools/ramp/upload-receipt

apps/sim/app/api/tools/ramp/upload-receipt/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ function buildReceiptMultipartBody(
3939
}
4040

4141
const safeFileName = file.name.replace(/[\r\n"]/g, '_')
42+
const safeContentType = file.type.replace(/[\r\n]/g, '') || 'application/octet-stream'
4243
parts.push(
4344
Buffer.from(
44-
`--${boundary}\r\nContent-Disposition: attachment; name="receipt"; filename="${safeFileName}"\r\nContent-Type: ${file.type}\r\n\r\n`
45+
`--${boundary}\r\nContent-Disposition: attachment; name="receipt"; filename="${safeFileName}"\r\nContent-Type: ${safeContentType}\r\n\r\n`
4546
)
4647
)
4748
parts.push(file.buffer)

0 commit comments

Comments
 (0)