File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -604,7 +604,14 @@ private function get_nice_filename($headers) {
604604
605605 if (!empty ($ originalfilename )) {
606606 $ result ['Content-Disposition ' ] = $ contentdisposition ;
607- $ result ['filename ' ] = 'filename=" ' . utf8_encode ($ originalfilename ) . '" ' ;
607+ // The filename parameter must be in ISO-8859-1, however it works in browsers if
608+ // you treat the original UTF-8 string as ISO-8859-1 characters. To achieve that
609+ // here, we encode the UTF-8 as if it were ISO-8859-1. Because this behaviour is
610+ // hideous, we also supply the original UTF-8 as the optional 'filename*' field
611+ // which is supposed to take precedence, and supports a specified encoding.
612+ $ jankyfilename = \core_text::convert ($ originalfilename , 'ISO-8859-1 ' );
613+ $ result ['filename ' ] = 'filename=" ' . $ jankyfilename .
614+ '"; filename*=UTF-8 \'\'" ' . $ originalfilename . '" ' ;
608615 $ result ['Content-Type ' ] = $ originalcontenttype ;
609616 }
610617 }
You can’t perform that action at this time.
0 commit comments