Skip to content

Commit

Permalink
Merge pull request #10489 from iMu3ic/fix_pattern_length_check
Browse files Browse the repository at this point in the history
Fix Uncaught RuntimeException: PHP Error: Uninitialized string offset 0 when $pattern is empty
  • Loading branch information
orklah committed Dec 14, 2023
2 parents 3bc8cde + c8748dc commit 64dc2ff
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
use function strpos;
use function strtolower;
use function substr;
use function trim;

/**
* @internal
Expand Down Expand Up @@ -636,17 +637,19 @@ private static function taintReturnType(
$first_arg_value = $first_stmt_type->getSingleStringLiteral()->value;

$pattern = substr($first_arg_value, 1, -1);
if (strlen(trim($pattern)) > 0) {
$pattern = trim($pattern);
if ($pattern[0] === '['
&& $pattern[1] === '^'
&& substr($pattern, -1) === ']'
) {
$pattern = substr($pattern, 2, -1);

if ($pattern[0] === '['
&& $pattern[1] === '^'
&& substr($pattern, -1) === ']'
) {
$pattern = substr($pattern, 2, -1);

if (self::simpleExclusion($pattern, $first_arg_value[0])) {
$removed_taints[] = 'html';
$removed_taints[] = 'has_quotes';
$removed_taints[] = 'sql';
if (self::simpleExclusion($pattern, $first_arg_value[0])) {
$removed_taints[] = 'html';
$removed_taints[] = 'has_quotes';
$removed_taints[] = 'sql';
}
}
}
}
Expand Down

0 comments on commit 64dc2ff

Please sign in to comment.