]> git.joonet.de Git - adminer.git/commitdiff
Compile: Move ?><? removal to php_shrink
authorJakub Vrana <jakub@vrana.cz>
Thu, 13 Mar 2025 16:33:42 +0000 (17:33 +0100)
committerJakub Vrana <jakub@vrana.cz>
Thu, 13 Mar 2025 16:43:20 +0000 (17:43 +0100)
compile.php
php_shrink.inc.php
tests/php_shrink.php

index 45b36021d908ddcaf6403d43d0fb2ec11261df1f..c261563215420d1990d6634bec265aab7f664263 100755 (executable)
@@ -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";
index f127493df4f8831d94fad4bd0319d8715dc04775..fe3b1c1834329d32934b7093751aa3752181ae60 100644 (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;
index 38faff32b311e10c5f6dbd0060e198ad5fd20954..95292b44bd23cb9127b8ef8cc14dfbe45f07c049 100644 (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;');