Skip to content
Snippets Groups Projects

Add CSP headers for svg files.

Closes #2868079

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
  • Lee Rowlands requested changes

    requested changes

  • added 1 commit

    Compare with previous version

  • added 1 commit

    • c4c498f7 - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • Lee Rowlands resolved all threads

    resolved all threads

  • added 1 commit

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • 15 /**
    16 * Sets Content-Security-Policy on file downloads.
    17 *
    18 * @param \Symfony\Component\HttpKernel\Event\ResponseEvent $event
    19 * The event to process.
    20 */
    21 public function onRespond(ResponseEvent $event): void {
    22 if (!$event->isMainRequest()) {
    23 return;
    24 }
    25
    26 $response = $event->getResponse();
    27
    28 if (!($response instanceof BinaryFileResponse)) {
    29 return;
    30 }
    • Comment on lines +27 to +30

      Is this condition actually necessary? I would have thought just the content type check below is fine.

    • This matches the class returned by \Drupal\system\FileDownloadController::download(), and limits the header to responses that are proxying a file from disk. If a dynamic response was outputting an SVG, this would skip it.

    • Please register or sign in to reply
  • added 1 commit

    • 62f868f9 - Apply 4 suggestion(s) to 4 file(s)

    Compare with previous version

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading