Permalink
Browse files

Fix XSS (thanks to Synopsi)

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@658 7c3ca157-0c34-0410-bff1-cbf682f78f5c
  • Loading branch information...
1 parent 629ff69 commit 35bca85a2e2aa4b54984eb07d4c90bb0f2fa563e jakubvrana committed Jun 6, 2009
Showing with 2 additions and 2 deletions.
  1. +2 −2 _compile.php
View
@@ -166,7 +166,6 @@ function php_shrink($input) {
$filename = "phpMinAdmin" . ($_COOKIE["lang"] ? "-$_COOKIE[lang]" : "") . ".php";
$file = file_get_contents(dirname(__FILE__) . "/index.php");
$file = preg_replace_callback('~\\b(include|require) "([^"]*)";~', 'put_file', $file);
-$file = preg_replace("~<\\?php\\s*\\?>|\\?>\n?<\\?php~", '', $file);
$file = preg_replace("~if \\(isset\\(\\\$_SESSION\\[\"coverage.*\n}\n| && !isset\\(\\\$_SESSION\\[\"coverage\"\\]\\)~sU", '', $file);
if ($_COOKIE["lang"]) {
$file = preg_replace_callback("~(<\\?php\\s*echo )?lang\\('((?:[^\\\\']+|\\\\.)*)'([,)])(;\\s*\\?>)?~s", 'remove_lang', $file);
@@ -175,7 +174,7 @@ function php_shrink($input) {
} else {
$file = preg_replace_callback("~lang\\('((?:[^\\\\']+|\\\\.)*)'([,)])~s", 'lang_ids', $file);
}
-$replace = 'preg_replace("~\\\\\\\\?.*~", "", $_SERVER["REQUEST_URI"]) . "?file=\\0&amp;version=' . $VERSION;
+$replace = 'htmlspecialchars(preg_replace("~\\\\\\\\?.*~", "", $_SERVER["REQUEST_URI"])) . "?file=\\0&amp;version=' . $VERSION;
$file = preg_replace('~default\\.css|functions\\.js|favicon\\.ico|(plus|cross)\\.gif~', '<?php echo ' . $replace . '"; ?>', $file);
$file = preg_replace('~(up|down|arrow)\\.gif~', '" . ' . $replace, $file);
$file = str_replace('error_reporting(E_ALL & ~E_NOTICE);', 'error_reporting(E_ALL & ~E_NOTICE);
@@ -203,6 +202,7 @@ function php_shrink($input) {
exit;
}', $file);
$file = str_replace("externals/jush/", "http://jush.sourceforge.net/", $file);
+$file = preg_replace("~<\\?php\\s*\\?>\n?|\\?>\n?<\\?php~", '', $file);
$file = php_shrink($file);
fwrite(fopen($filename, "w"), $file);
echo "$filename created.\n";

0 comments on commit 35bca85

Please sign in to comment.