maildev icon indicating copy to clipboard operation
maildev copied to clipboard

Fix crash when attachment with contentId containing /

Open tmoinel opened this issue 2 years ago • 0 comments

When an email is rec ivied with a contentId containing a slash / it fail with

node:events:505
      throw er; // Unhandled 'error' event
      ^

Error: ENOENT: no such file or directory, open '/tmp/maildev-244388/H7awAzl6/folder/image'
Emitted 'error' event on WriteStream instance at:
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/tmp/maildev-244388/H7awAzl6/folder/image'
}

I fixed it using encodeURIComponent when reading or writing to disk.

I also include a test case.

tmoinel avatar Jul 26 '22 18:07 tmoinel