mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Merge pull request #10489 from iMu3ic/fix_pattern_length_check
Fix Uncaught RuntimeException: PHP Error: Uninitialized string offset 0 when $pattern is empty
This commit is contained in:
commit
64dc2ff747
@ -51,6 +51,7 @@ use function strlen;
|
||||
use function strpos;
|
||||
use function strtolower;
|
||||
use function substr;
|
||||
use function trim;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
@ -636,17 +637,19 @@ final class FunctionCallReturnTypeFetcher
|
||||
$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';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user