From cea6d381a4b00108baed0a29c0e4161b033e17b4 Mon Sep 17 00:00:00 2001 From: christianbeeznst Date: Fri, 17 May 2024 12:01:39 -0500 Subject: [PATCH] Internal: Fix special character issue in file attachments for downloads - BT#21707 --- src/CoreBundle/Controller/ResourceController.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/CoreBundle/Controller/ResourceController.php b/src/CoreBundle/Controller/ResourceController.php index 2256f816b0..1b00956a4e 100644 --- a/src/CoreBundle/Controller/ResourceController.php +++ b/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('', $links.'', $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