From: Alexander Ebert
Date: Thu, 30 Mar 2023 16:18:33 +0000 (+0200)
Subject: Use a regex to insert a whitespace instead of stripping the tags
X-Git-Tag: 5.5.11_dev_1~10^2
X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=bae7f6414bb8f7f18ac0e220aa6ef2e277041229;p=GitHub%2FWoltLab%2FWCF.git
Use a regex to insert a whitespace instead of stripping the tags
---
diff --git a/wcfsetup/install/files/lib/system/search/SearchIndexManager.class.php b/wcfsetup/install/files/lib/system/search/SearchIndexManager.class.php
index a9f887422a..fc42640306 100644
--- a/wcfsetup/install/files/lib/system/search/SearchIndexManager.class.php
+++ b/wcfsetup/install/files/lib/system/search/SearchIndexManager.class.php
@@ -122,23 +122,9 @@ class SearchIndexManager extends SingletonFactory implements ISearchIndexManager
$languageID = null,
$metaData = ''
) {
- // Force replace certain tags with a whitespace to prevent words from adjacent
- // lines to be glued together.
- $message = \str_replace([
- '
',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '
',
- '',
- '',
- '',
- ], ' ', $message);
+ // Inserts a whitespace after certain tags to prevent words from adjacent
+ // lines to be effectively be glued together when the tags are removed.
+ $message = \preg_replace('~(
|(?:h[1-6]|kbd|li|p|pre|td|woltlab-metacode)>)~', '\\1 ', $message);
// strip html; remove whitespace from beginning and end of the message
$message = StringUtil::trim(StringUtil::stripHTML($message));