From 6abdb0d593a521702172cdbc40b312f611703f6d Mon Sep 17 00:00:00 2001 From: celestora Date: Sat, 25 Feb 2023 18:08:17 +0200 Subject: [PATCH] Further improvements to TRichText Fix link parsing + remove zalgo completely --- Web/Models/Entities/Traits/TRichText.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Web/Models/Entities/Traits/TRichText.php b/Web/Models/Entities/Traits/TRichText.php index ed1c8df0..dc78a034 100644 --- a/Web/Models/Entities/Traits/TRichText.php +++ b/Web/Models/Entities/Traits/TRichText.php @@ -36,7 +36,7 @@ trait TRichText "%(([A-z]++):\/\/(\S*?\.\S*?))([\s)\[\]{},\"\'<]|\.\s|$)%", (function (array $matches): string { $href = str_replace("#", "#", $matches[1]); - $href = rawurlencode(str_replace(";", ";", $matches[1])); + $href = rawurlencode(str_replace(";", ";", $href)); $link = str_replace("#", "#", $matches[3]); $link = str_replace(";", ";", $link); $rel = $this->isAd() ? "sponsored" : "ugc"; @@ -49,7 +49,7 @@ trait TRichText private function removeZalgo(string $text): string { - return preg_replace("%\p{M}{3,}%Xu", "�", $text); + return preg_replace("%\p{M}{3,}%Xu", "", $text); } function resolveMentions(array $skipUsers = []): \Traversable