From 900d1fd4db37ac527fba8166d5a1f128a1757b48 Mon Sep 17 00:00:00 2001 From: Sergey Boborykin Date: Fri, 14 Apr 2023 21:08:10 +0300 Subject: [PATCH 1/2] fix Message::bodySummary when preg_replace is broken preg_replace returns "false" on failure which interpreted as OK result which is wrong. Reform statement in positive manner makes it right --- src/Message.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Message.php b/src/Message.php index 61c1a5dc..7b94840c 100644 --- a/src/Message.php +++ b/src/Message.php @@ -77,11 +77,11 @@ public static function bodySummary(MessageInterface $message, int $truncateAt = // Matches any printable character, including unicode characters: // letters, marks, numbers, punctuation, spacing, and separators. - if (preg_match('/[^\pL\pM\pN\pP\pS\pZ\n\r\t]/u', $summary)) { - return null; + if (preg_match('/[^\pL\pM\pN\pP\pS\pZ\n\r\t]/u', $summary) === 0) { + return $summary; } - return $summary; + return null; } /** From e06bc700cd320871124228048cd14d1c852013f8 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Mon, 17 Apr 2023 14:08:09 +0100 Subject: [PATCH 2/2] Flipped logic back --- src/Message.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Message.php b/src/Message.php index 7b94840c..c1e15f82 100644 --- a/src/Message.php +++ b/src/Message.php @@ -77,11 +77,11 @@ public static function bodySummary(MessageInterface $message, int $truncateAt = // Matches any printable character, including unicode characters: // letters, marks, numbers, punctuation, spacing, and separators. - if (preg_match('/[^\pL\pM\pN\pP\pS\pZ\n\r\t]/u', $summary) === 0) { - return $summary; + if (preg_match('/[^\pL\pM\pN\pP\pS\pZ\n\r\t]/u', $summary) !== 0) { + return null; } - return null; + return $summary; } /**