From 50fbd637f2fa51a2978c69af6e2ee094edecc7e4 Mon Sep 17 00:00:00 2001 From: Ihor Mandzyuk Date: Fri, 31 Mar 2023 11:21:12 +0300 Subject: [PATCH 1/2] fixed part of tag show in short content --- Model/ShortContentExtractor.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Model/ShortContentExtractor.php b/Model/ShortContentExtractor.php index 0de78353..5f7b2afd 100644 --- a/Model/ShortContentExtractor.php +++ b/Model/ShortContentExtractor.php @@ -130,16 +130,16 @@ public function execute($content, $len = null, $endCharacters = null) } /* Do not cut words */ - while ($len < strlen($content) + while ($len < mb_strlen($content) && !in_array($content[$len], [' ', '<', "\t", "\r", "\n"])) { $len++; } - $content = mb_substr($content, 0, $len); + $content = mb_strcut($content, 0, $len); try { $previousErrorState = libxml_use_internal_errors(true); $dom = new \DOMDocument(); - $dom->loadHTML('' . $content); + $dom->loadHTML('' . '' . $content . ''); libxml_use_internal_errors($previousErrorState); $body = $dom->getElementsByTagName('body'); From 768ae0ed33d155ccbe2bd8363d39743897164694 Mon Sep 17 00:00:00 2001 From: Magefan Date: Fri, 31 Mar 2023 17:02:12 +0300 Subject: [PATCH 2/2] Update ShortContentExtractor.php --- Model/ShortContentExtractor.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Model/ShortContentExtractor.php b/Model/ShortContentExtractor.php index 5f7b2afd..3f3d60a0 100644 --- a/Model/ShortContentExtractor.php +++ b/Model/ShortContentExtractor.php @@ -131,11 +131,11 @@ public function execute($content, $len = null, $endCharacters = null) /* Do not cut words */ while ($len < mb_strlen($content) - && !in_array($content[$len], [' ', '<', "\t", "\r", "\n"])) { + && !in_array(mb_substr($content, $len, 1), [' ', '<', "\t", "\r", "\n"])) { $len++; } - $content = mb_strcut($content, 0, $len); + $content = mb_substr($content, 0, $len); try { $previousErrorState = libxml_use_internal_errors(true); $dom = new \DOMDocument();