Skip to content

Commit

Permalink
check php whitelist only if it is not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcus Schwarz authored and usox committed Jun 27, 2018
1 parent 309f715 commit 6c42c98
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Php/TalesInternal.php
Original file line number Diff line number Diff line change
Expand Up @@ -700,13 +700,18 @@ private static function tokenize($src)
private static function checkTokens($src)
{

$checkWhitelist = static::$functionWhitelist !== [];

foreach (static::tokenize($src) as $token) {
if (in_array($token[0], static::$tokenBlacklist)) {
$message = 'User tried to execute disallowed php token ' . token_name($token[0]);
throw new ParserException($message);
}

if ($token[0] === T_STRING && !in_array(strtolower($token[1]), static::$functionWhitelist)) {
if ($checkWhitelist &&
$token[0] === T_STRING &&
!in_array(strtolower($token[1]), static::$functionWhitelist)
) {
$message = "User tried to execute not whitelisted statement '" . $token[1] . "'";
throw new ParserException($message);
}
Expand Down

0 comments on commit 6c42c98

Please sign in to comment.