fix mb_strpos empty delimiter

This commit is contained in:
sunxyw 2022-03-27 01:08:40 +08:00
parent 50f06e6a4f
commit 3cfcbaec16
No known key found for this signature in database
GPG Key ID: CEA01A083E98C578

View File

@ -96,10 +96,10 @@ function unicode_decode(string $str): ?string
*/
function match_pattern(string $pattern, string $subject): bool
{
if (mb_strpos($pattern, '') === 0 && mb_strpos($subject, '') === 0) {
if (empty($pattern) && empty($subject)) {
return true;
}
if (mb_strpos($pattern, '*') === 0 && mb_substr($pattern, 1, 1) !== '' && mb_strpos($subject, '') === 0) {
if (mb_strpos($pattern, '*') === 0 && mb_substr($pattern, 1, 1) !== '' && empty($subject)) {
return false;
}
if (mb_strpos($pattern, mb_substr($subject, 0, 1)) === 0) {