From 3cfcbaec167a271db3a88b38cac064ddb82c4ace Mon Sep 17 00:00:00 2001 From: sunxyw Date: Sun, 27 Mar 2022 01:08:40 +0800 Subject: [PATCH] fix mb_strpos empty delimiter --- src/ZM/global_functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ZM/global_functions.php b/src/ZM/global_functions.php index 2e6a455f..54ee5efc 100644 --- a/src/ZM/global_functions.php +++ b/src/ZM/global_functions.php @@ -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) {