This commit is contained in:
Laurent Destailleur
2020-10-07 17:17:13 +02:00
parent 24295b309d
commit 561ca757d7

View File

@@ -2387,14 +2387,15 @@ function price2fec($amount)
/** /**
* Check the syntax of some PHP code. * Check the syntax of some PHP code.
*
* @param string $code PHP code to check. * @param string $code PHP code to check.
* @return boolean|array If false, then check was successful, otherwise an array(message,line) of errors is returned. * @return boolean|array If false, then check was successful, otherwise an array(message,line) of errors is returned.
*/ */
function phpSyntaxError($code) function phpSyntaxError($code)
{ {
if (!defined("CR")) define("CR","\r"); if (!defined("CR")) define("CR", "\r");
if (!defined("LF")) define("LF","\n") ; if (!defined("LF")) define("LF", "\n");
if (!defined("CRLF")) define("CRLF","\r\n") ; if (!defined("CRLF")) define("CRLF", "\r\n");
$braces=0; $braces=0;
$inString=0; $inString=0;
@@ -2406,14 +2407,16 @@ function phpSyntaxError($code)
case T_START_HEREDOC: ++$inString; break; case T_START_HEREDOC: ++$inString; break;
case T_END_HEREDOC: --$inString; break; case T_END_HEREDOC: --$inString; break;
} }
} else if ($inString & 1) { } elseif ($inString & 1) {
switch ($token) { switch ($token) {
case '`': case '\'': case '`':
case '\'':
case '"': --$inString; break; case '"': --$inString; break;
} }
} else { } else {
switch ($token) { switch ($token) {
case '`': case '\'': case '`':
case '\'':
case '"': ++$inString; break; case '"': ++$inString; break;
case '{': ++$braces; break; case '{': ++$braces; break;
case '}': case '}':
@@ -2436,8 +2439,8 @@ function phpSyntaxError($code)
if ($braces) { if ($braces) {
$braces = PHP_INT_MAX; $braces = PHP_INT_MAX;
} else { } else {
false !== strpos($code,CR) && $code = strtr(str_replace(CRLF,LF,$code),CR,LF); false !== strpos($code, CR) && $code = strtr(str_replace(CRLF, LF, $code), CR, LF);
$braces = substr_count($code,LF); $braces = substr_count($code, LF);
} }
$code = ob_get_clean(); $code = ob_get_clean();
$code = strip_tags($code); $code = strip_tags($code);
@@ -2455,4 +2458,3 @@ function phpSyntaxError($code)
@ini_set('log_errors', $inString); @ini_set('log_errors', $inString);
return $code; return $code;
} }