Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve filename sanitization in MIME headers #388

Merged
merged 6 commits into from
Nov 26, 2024

Commits on Nov 26, 2024

  1. Improve filename sanitization in MIME headers

    Sanitize filenames to replace invalid characters before encoding them. This prevents control and special characters from causing issues in MIME headers and file systems. The `sanitizeFilename` function ensures these characters are replaced with underscores.
    wneessen committed Nov 26, 2024
    Configuration menu
    Copy the full SHA
    8f8b507 View commit details
    Browse the repository at this point in the history
  2. Add tests for the sanitizeFilename function

    This commit introduces a series of tests for the sanitizeFilename function in msgwriter_test.go. The tests cover various edge cases to ensure filenames are sanitized correctly by replacing or removing invalid characters. These additions will help maintain the integrity and reliability of filename sanitization in the codebase.
    wneessen committed Nov 26, 2024
    Configuration menu
    Copy the full SHA
    b051471 View commit details
    Browse the repository at this point in the history
  3. Add filename sanitization tests for attachments

    Introduced tests to validate filename sanitization for attachments, ensuring disallowed characters are handled correctly. These tests cover various scenarios, including different character sets such as Japanese, Chinese, and Cyrillic.
    wneessen committed Nov 26, 2024
    Configuration menu
    Copy the full SHA
    fe765cd View commit details
    Browse the repository at this point in the history
  4. Simplify attachment test setup

    Removed temporary file creation and copying in msgwriter_test.go. Directly attach the source file during the test to streamline the setup process. This change reduces complexity and potential points of failure in the test code.
    wneessen committed Nov 26, 2024
    Configuration menu
    Copy the full SHA
    75c0e33 View commit details
    Browse the repository at this point in the history
  5. Update content-type handling for FreeBSD in msgwriter test

    Adjusted the expected content-type header in msgwriter tests to account for FreeBSD by setting it to 'application/octet-stream' instead of 'text/plain'. This ensures compatibility and correct behavior across different operating systems.
    wneessen committed Nov 26, 2024
    Configuration menu
    Copy the full SHA
    f61da9c View commit details
    Browse the repository at this point in the history
  6. Remove charset from octet-stream Content-Type on FreeBSD

    The charset parameter in the Content-Type header for octet-stream files on FreeBSD was removed. This aligns the behavior with the expected MIME type format for such files. Other platforms remain unchanged.
    wneessen committed Nov 26, 2024
    Configuration menu
    Copy the full SHA
    06bee90 View commit details
    Browse the repository at this point in the history