PhpMyAdmin源代码中的不可读字符 [英] Unreadible characters in PhpMyAdmin sources

查看:126
本文介绍了PhpMyAdmin源代码中的不可读字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Ubuntu 12上安装了PMA 4.0.7:

I install PMA 4.0.7 on Ubuntu 12 :

wget http://www.sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/4.0.7/phpMyAdmin-4.0.7-all-languages.tar.bz2

tar -jxf phpMyAdmin-4.0.7-all-languages.tar.bz2

但是无法在浏览器中打开它,Chrome显示空白页..控制台中出现错误:

But can't open it in browser, Chrome displays blank page .. with error in console :

Uncaught SyntaxError: Unexpected token ILLEGAL get_scripts.js.php:13876

CodeMirror.defineMIME("text/x-mysql", "mysql");
;

�  // <- unreadible character goes there

有人可以帮助我吗?

谢谢!

推荐答案

我也遇到了这个问题.事实证明文件是通过HTTP 1.1发送的,而b/c没有Content-Length标头,则以分块编码的形式出现.多余的字符归因于不完整的块.我将get_scripts.js.php文件修改为此,现在对我有用:

I had this problem, too. Turns out that the file is being sent as HTTP 1.1 which, b/c it doesn't have a Content-Length header, comes out as chunked encoding. The extra characters are due to the incomplete chunk. I modified the get_scripts.js.php file to this and it now works for me:

<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * Concatenates reveral js files to reduce the number of
 * http requests sent to the server
 *
 * @package PhpMyAdmin
 */
chdir('..');

// Send correct type
header('Content-Type: text/javascript; charset=UTF-8');
// Enable browser cache for 1 hour
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 3600) . ' GMT');

if (! empty($_GET['scripts']) && is_array($_GET['scripts'])) {
    $total_length = 0;
    foreach ($_GET['scripts'] as $script) {
        // Sanitise filename
        $script_name = 'js';
        $path = explode("/", $script);
        foreach ($path as $index => $filename) {
            if (! preg_match("@^\.+$@", $filename)
                && preg_match("@^[\w\.-]+$@", $filename)
            ) {
                // Disallow "." and ".." alone
                // Allow alphanumeric, "." and "-" chars only
                $script_name .= DIRECTORY_SEPARATOR . $filename;
            }
        }
        // Count file size
        if (preg_match("@\.js$@", $script_name) && is_readable($script_name)) {
            $total_length += filesize($script_name) + 3;
        }
    }
    header('Content-Length: '.$total_length);
    foreach ($_GET['scripts'] as $script) {
      // Sanitise filename
      $script_name = 'js';
      $path = explode("/", $script);
      foreach ($path as $index => $filename) {
        if (! preg_match("@^\.+$@", $filename)
            && preg_match("@^[\w\.-]+$@", $filename)
        ) {
          // Disallow "." and ".." alone
          // Allow alphanumeric, "." and "-" chars only
          $script_name .= DIRECTORY_SEPARATOR . $filename;
        }
      }
      // Output file contents
      if (preg_match("@\.js$@", $script_name) && is_readable($script_name)) {
          readfile($script_name);
          echo ";\n\n";
      }
    }
}
?>

这篇关于PhpMyAdmin源代码中的不可读字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆