アップロードしたテキストファイルの文字化け対策

アップロードしたテキストファイルの文字化け対策

- Mitsuhiro Yoshida の投稿
返信数: 0
画像 Developers 画像 Particularly helpful Moodlers 画像 Translators
Moodle1.5.2で、アップロードしたテキストファイルを閲覧すると文字化けする場合があります。
moodle/lib/filelib.phpの200行目あたりを下記のように変更すると、文字化けしなくなりますので、お試しください。wink

Index: lib/filelib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/filelib.php,v
retrieving revision 1.13
diff -u -r1.13 filelib.php
--- lib/filelib.php    4 Aug 2005 18:31:59 -0000    1.13
+++ lib/filelib.php    3 Sep 2005 16:04:42 -0000
@@ -200,11 +200,11 @@
         } else if ($mimetype == 'text/plain') {
             $options->newlines = false;
             $options->noclean = true;
           $text = htmlentities($pathisstring ? $path : implode('', file($path)));
+            $text = htmlspecialchars($pathisstring ? $path : implode('', file($path)));
             $output = '<pre>'. format_text($text, FORMAT_MOODLE, $options, $courseid) .'</pre>';

             @header('Content-length: '.strlen($output));
           @header('Content-type: text/html; charset='. get_string('thischarset')); //add encoding
+            @header('Content-type: text/html');
             echo $output;
         } else {    // Just send it out raw
             @header('Content-length: '.$filesize);

この件は、Moodle Bug Tracker ( http://moodle.org/bugs/ ) に報告させていただきます。