Commit MetaInfo

修订版70fa3802880f914bd6b33bb3bae465a06a62151a (tree)
时间2014-07-13 05:02:56
作者umorigu <umorigu@gmai...>
Commiterumorigu

Log Message

BugTrack2/354: Implement RFC 6266 to support non-ASCII filename of Attach

* RFC 6266: Use of the Content-Disposition Header Field in the Hypertext Transfer Protocol

* RFC2231: MIME Parameter Value and Encoded Word Extensions: Character Sets, Languages, and Continuations

* RFC 5987: Character Set and Language Encoding for Hypertext Transfer Protocol (HTTP) Header Field Parameters

更改概述

差异

--- a/plugin/attach.inc.php
+++ b/plugin/attach.inc.php
@@ -711,13 +711,13 @@ EOD;
711711 break;
712712 }
713713 }
714- $filename = htmlsc($filename);
714+ $utf8filename = mb_convert_encoding($filename, 'UTF-8', 'auto');
715715
716716 ini_set('default_charset', '');
717717 mb_http_output('pass');
718718
719719 pkwk_common_headers();
720- header('Content-Disposition: inline; filename="' . $filename . '"');
720+ header('Content-Disposition: inline; filename="' . $filename . '"; filename*=utf-8\'\'' . rawurlencode($utf8filename));
721721 header('Content-Length: ' . $this->size);
722722 header('Content-Type: ' . $this->type);
723723
--- a/plugin/ref.inc.php
+++ b/plugin/ref.inc.php
@@ -420,12 +420,12 @@ function plugin_ref_action()
420420 break;
421421 }
422422 }
423- $file = htmlsc($filename);
423+ $utf8filename = mb_convert_encoding($filename, 'UTF-8', 'auto');
424424 $size = filesize($ref);
425425
426426 // Output
427427 pkwk_common_headers();
428- header('Content-Disposition: inline; filename="' . $filename . '"');
428+ header('Content-Disposition: inline; filename="' . $filename . '"; filename*=utf-8\'\'' . rawurlencode($utf8filename));
429429 header('Content-Length: ' . $size);
430430 header('Content-Type: ' . $type);
431431 @readfile($ref);
Show on old repository browser