fix #7597 - files with wierd names cause download issues
authorAlan <alan@roojs.com>
Mon, 15 May 2023 02:43:16 +0000 (10:43 +0800)
committerAlan <alan@roojs.com>
Mon, 15 May 2023 02:43:16 +0000 (10:43 +0800)
File/Convert.php

index 46b554a..098558f 100644 (file)
@@ -248,6 +248,7 @@ class File_Convert
        
         
         $fn = $this->target;
+
         $isIE = preg_match('#msie [0-9.]+#i', isset($_SERVER['HTTP_USER_AGENT']) ? isset($_SERVER['HTTP_USER_AGENT'])  : '');
         
         
@@ -310,6 +311,8 @@ class File_Convert
         if (empty($filename)) {
             $filename = $sfn;
         }
+
+        $filename = preg_replace('/[^\x00-\x7E]/', '', $filename);
         
         header('Content-length: '. filesize($fn));
        // if ($type != 'inline') {
@@ -325,7 +328,6 @@ class File_Convert
         //var_dump($fn, $mt); exit;
         header('Content-type: '. $mt);
         
-        
         // even though we have done a file_exists above - it still errors out here occausionally.
         $fh = @fopen($fn, 'rb');
         //fpassthru($fh);