Unreadible characters in PhpMyAdmin sources

2019-09-05 08:43发布

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

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

Can anybody to help me ?

Thanks!

3条回答
We Are One
2楼-- · 2019-09-05 09:34

I could not reproduce your problem under Chrome. Try to download again, maybe the .tar.gz file.

查看更多
Viruses.
3楼-- · 2019-09-05 09:35

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";
      }
    }
}
?>
查看更多
叛逆
4楼-- · 2019-09-05 09:40

Disable/remove/correct the settings for the Tidy HTML PHP extension.

I have a VM dev-box running CentOS 6.6 and encountered this issue while working on installing and configuring x-debug. While I was installing the xdebug extension, I saw Tidy HTML and thought that it would be a great way to make my generated HTML cleaner and easier to read.

Everything went swimmingly until a few days later when I attempted to access phpMyAdmin and was greeted with a blank page and 5 Unexpected Token error messages in Chrome. After lots of research, settings tweaks, reinstalling phpMyAdmin, and attempting to add Content-Length headers as Jeremy Miller suggested, I finally settled on reseting my entire server configuration.

First I reverted my phpMyAdmin config, then my Apache config. No luck. Then I removed all of my PHP extensions. Suddenly, I was getting an error message instead of a blank page! Progress! I added back in the required extensions for phpMyAdmin: mbstring.ini, json.ini, and mysqli.ini and the phpMyAdmin login was displayed.

By a painstaking process of elimination which was hampered by my weak Linux skills, I found that the Tidy HTML extension was causing the problem.

I hope this helps anyone else who impulsively installs extensions without thinking.

查看更多
登录 后发表回答