1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-06 22:56:46 +02:00

Compile: Move ?><? removal to php_shrink

This commit is contained in:
Jakub Vrana
2025-03-13 17:33:42 +01:00
parent 9afbf1a465
commit 4c2a8b0050
3 changed files with 2 additions and 1 deletions

View File

@@ -350,7 +350,6 @@ $file = preg_replace('~\.\./adminer/static/(default\.css|favicon\.ico)~', '<?php
$file = preg_replace('~"\.\./adminer/static/(functions\.js)"~', $replace, $file);
$file = preg_replace('~\.\./adminer/static/([^\'"]*)~', '" . h(' . $replace . ') . "', $file);
$file = preg_replace('~"\.\./externals/jush/modules/(jush\.js)"~', $replace, $file);
$file = preg_replace("~<\\?php\\s*\\?>\n?|\\?>\n?<\\?php~", '', $file);
$file = php_shrink($file);
$filename = $project . (preg_match('~-dev$~', $VERSION) ? "" : "-$VERSION") . ($driver ? "-$driver" : "") . ($_SESSION["lang"] ? "-$_SESSION[lang]" : "") . ".php";

View File

@@ -13,6 +13,7 @@
*/
function php_shrink($input) {
// based on http://latrine.dgx.cz/jak-zredukovat-php-skripty
$input = preg_replace("~<\\?php\\s*\\?>\n?|\\?>\n?<\\?php~", '', $input);
$special_variables = array_flip(array('$this', '$GLOBALS', '$_GET', '$_POST', '$_FILES', '$_COOKIE', '$_SESSION', '$_SERVER', '$http_response_header', '$php_errormsg'));
$short_variables = array();
$shortening = true;

View File

@@ -33,3 +33,4 @@ check('$ab = 1; echo "$ab";', '$a=1;echo"$a";');
check('echo 1; echo 3;', 'echo 1,3;');
check('echo 1; ?>2<?php echo 3;', "echo 1,'2',3;");
check('/** preserve*/ $a; /** ignore */ /* also ignore */ // ignore too', '/** preserve*/$a;');
check('$a = 1; ?><?php ?><?php $a = 2;', '$a=1;$a=2;');