Skip to content

Add RFC 5987/6266 UTF-8 filename support in Content-Disposition header #7

Closed

Description

@joanfabregat

Description

The SpreadsheetResponse class currently relies on Symfony's HeaderUtils::makeDisposition() for setting the Content-Disposition header. However, it would be beneficial to ensure that UTF-8 filenames with special characters (like accents) are properly supported using RFC 5987/6266.

Current Behavior

When a filename contains accents or special characters (e.g., "Liste des utilisateurs avec données.xlsx"), it may not be handled correctly by all browsers.

Expected Behavior

The Content-Disposition header should include both:

  • filename="ascii-fallback.xlsx" - ASCII filename for older browsers
  • filename*=UTF-8''utf8-filename.xlsx" - UTF-8 encoded filename for modern browsers

Example:

Content-Disposition: attachment; filename="Liste des utilisateurs avec donnees.xlsx"; filename*=UTF-8''Liste%20des%20utilisateurs%20avec%20donn%C3%A9es.xlsx

Proposed Solution

Verify that Symfony's HeaderUtils::makeDisposition() is being used correctly with UTF-8 filenames, or implement custom handling if needed to ensure RFC 5987/6266 compliance.

Context

This issue was identified while implementing UTF-8 filename support in a project using this library. The legacy download mechanism was updated to support RFC 5987/6266, and it would be good to ensure the modern SpreadsheetResponse approach also handles this correctly.

Activity

  1. added a commit that references this issue on Jan 23, 2026
    da124e6
  2. joanfabregat commented on Jan 23, 2026

    @joanfabregat
    MemberAuthor

    Investigation & Resolution

    After investigating the current implementation, I found that RFC 5987/6266 UTF-8 filename support is already working correctly through Symfony's HeaderUtils::makeDisposition().

    When a filename contains non-ASCII characters, the Content-Disposition header correctly includes both formats:

    • filename="ascii-fallback.xlsx" - ASCII fallback for older browsers
    • filename*=utf-8''encoded.xlsx - UTF-8 encoded filename for modern browsers

    For example, with Liste des utilisateurs avec données.xlsx, the header generates:

    Content-Disposition: attachment; filename=Liste-des-utilisateurs-avec-donn-es.xlsx; filename*=utf-8''Liste%20des%20utilisateurs%20avec%20donn%C3%A9es.xlsx
    

    What was added in PR #8:

    • Comprehensive tests verifying RFC 5987/6266 compliance
    • Tests for various international characters (French, German, Spanish, Chinese, Japanese)
    • Documentation in test comments explaining the expected behavior

    No changes to the main SpreadsheetResponse class were needed - the implementation was already correct.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions