Skip to content
Snippets Groups Projects

Add support for filename Extended

Open nicxvan requested to merge issue/drupal-3276349:3276349-filename-parameter into 11.x
1 unresolved thread

Closes #3276349

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
13 13 /**
14 14 * The regex used to extract the filename from the content disposition header.
15 15 */
16 const REQUEST_HEADER_FILENAME_REGEX = '@\bfilename(?<star>\*?)=\"(?<filename>.+)\"@';
16 const REQUEST_HEADER_FILENAME_REGEX = '@\bfilename=\"(?<filename>.+)\"@';
17
18 /**
19 * The regex used to extract an extended filename from the content disposition header.
20 *
21 * @var string
22 */
23 const REQUEST_HEADER_EXTENDED_FILENAME_REGEX = "@\bfilename\*=\"(?<charset>[\w-]+)'(?<lang>\w*)'(?<filename>.+)\"@";
  • This single regex seems to handle it https://www.phpliveregex.com/p/Mzq

    \bfilename(\*)?=?(?(1)"(?<charset>[\w-]+)?('(?<lang>\w*)')?|)(?<filename>.+)"

    we only look for charset/lang if the * is found

  • Please register or sign in to reply
    Loading