Skip to content

RFC 2231 encoding for non-ASCII attachment filenames #3

Description

@devopsmitch

Summary

Attachment filenames are placed inside a Content-Disposition: attachment; filename="..." parameter. The current quoteFilename helper strips CR/LF and the quoted-string specials (" and \) to prevent header injection and quote breakout, which is safe — but it does not RFC 2047 / RFC 2231 encode non-ASCII filenames.

As a result, a filename containing non-ASCII characters (e.g. résumé.pdf, 報告書.pdf) remains as raw bytes inside the quoted string. It stays safe and within a valid quoted value, but may not render correctly in all mail clients.

Possible direction

  • Encode non-ASCII filenames using RFC 2231 (filename*=UTF-8''...) alongside a sanitized ASCII filename="..." fallback for older clients.

Notes

  • This is a correctness/interoperability improvement, not a security issue — injection and quote-breakout are already prevented (see mail.quoteFilename and its tests).

Priority

Low — nice to have. ASCII filenames are unaffected.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestlow priorityNice to have; may be addressed eventually

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions