From 76101bfcb92c2b1f54798b1e598113a24a570a1c Mon Sep 17 00:00:00 2001 From: rauwebieten Date: Wed, 13 Sep 2017 16:25:12 +0200 Subject: [PATCH] IE content-disposition bugfix --- src/Psr7PartialDownload.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Psr7PartialDownload.php b/src/Psr7PartialDownload.php index 0321711..5f92346 100644 --- a/src/Psr7PartialDownload.php +++ b/src/Psr7PartialDownload.php @@ -29,8 +29,9 @@ public function sendFile(ServerRequestInterface $request, ResponseInterface $res $invalidChars = array('<', '>', '?', '"', ':', '|', '\\', '/', '*', '&'); $fileName = str_replace($invalidChars, '', $fileName); - if (preg_match('/MSIE/', $_SERVER['HTTP_USER_AGENT'])) { - $fileName = rawurlencode($fileName); + // normalize to prevent utf8 problems + if (class_exists('\Normalizer')) { + $fileName = preg_replace('/\p{Mn}/u', '', \Normalizer::normalize($fileName, \Normalizer::FORM_KD)); } $response = $response->withHeader('Content-Type', $contentType);