OSDN Git Service

BugTrack2/354: Implement RFC 6266 to support non-ASCII filename of Attach r1_5_0_rc1
authorumorigu <umorigu@gmail.com>
Mon, 7 Jul 2014 16:05:23 +0000 (01:05 +0900)
committerumorigu <umorigu@gmail.com>
Sat, 12 Jul 2014 20:02:56 +0000 (05:02 +0900)
* RFC 6266: Use of the Content-Disposition Header Field in the Hypertext Transfer Protocol
  - http://www.ietf.org/rfc/rfc6266.txt
* RFC2231: MIME Parameter Value and Encoded Word Extensions: Character Sets, Languages, and Continuations
  - http://www.ietf.org/rfc/rfc2231.txt
* RFC 5987: Character Set and Language Encoding for Hypertext Transfer Protocol (HTTP) Header Field Parameters
  - http://www.ietf.org/rfc/rfc5987.txt

plugin/attach.inc.php
plugin/ref.inc.php

index ce7f70e..355a428 100644 (file)
@@ -711,13 +711,13 @@ EOD;
                                break;
                        }
                }
-               $filename = htmlsc($filename);
+               $utf8filename = mb_convert_encoding($filename, 'UTF-8', 'auto');
 
                ini_set('default_charset', '');
                mb_http_output('pass');
 
                pkwk_common_headers();
-               header('Content-Disposition: inline; filename="' . $filename . '"');
+               header('Content-Disposition: inline; filename="' . $filename . '"; filename*=utf-8\'\'' . rawurlencode($utf8filename));
                header('Content-Length: ' . $this->size);
                header('Content-Type: '   . $this->type);
 
index cb3fe32..f0095cf 100644 (file)
@@ -420,12 +420,12 @@ function plugin_ref_action()
                        break;
                }
        }
-       $file = htmlsc($filename);
+       $utf8filename = mb_convert_encoding($filename, 'UTF-8', 'auto');
        $size = filesize($ref);
 
        // Output
        pkwk_common_headers();
-       header('Content-Disposition: inline; filename="' . $filename . '"');
+       header('Content-Disposition: inline; filename="' . $filename . '"; filename*=utf-8\'\'' . rawurlencode($utf8filename));
        header('Content-Length: ' . $size);
        header('Content-Type: '   . $type);
        @readfile($ref);