Merge pull request #5519 from christianbeeznest/ofaj-21707

Internal: Fix special character issue in file attachments for downloads - BT#21707
pull/5520/head
christianbeeznest 6 months ago committed by GitHub
commit a61358bde0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 9
      src/CoreBundle/Controller/ResourceController.php

@ -456,7 +456,7 @@ class ResourceController extends AbstractResourceController implements CourseCon
/**
* @return mixed|StreamedResponse
*/
private function processFile(Request $request, ResourceNode $resourceNode, string $mode = 'show', string $filter = '', ?array $allUserInfo = null)
private function processFile(Request $request, ResourceNode $resourceNode, string $mode = 'show', string $filter = '', ?array $allUserInfo = null): mixed
{
$this->denyAccessUnlessGranted(
ResourceNodeVoter::VIEW,
@ -554,9 +554,6 @@ class ResourceController extends AbstractResourceController implements CourseCon
$content = str_replace('</head>', $links.'</head>', $content);
}
$response->setContent($content);
/*$contents = $this->renderView('@ChamiloCore/Resource/view_html.twig', [
'category' => '...',
]);*/
return $response;
}
@ -572,7 +569,9 @@ class ResourceController extends AbstractResourceController implements CourseCon
}
);
// Transliterator::transliterate($fileName)
// Convert the file name to ASCII using iconv
$fileName = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $fileName);
$disposition = $response->headers->makeDisposition(
$forceDownload ? ResponseHeaderBag::DISPOSITION_ATTACHMENT : ResponseHeaderBag::DISPOSITION_INLINE,
$fileName

Loading…
Cancel
Save