Further improvements to TRichText

Fix link parsing + remove zalgo completely
This commit is contained in:
celestora 2023-02-25 18:08:17 +02:00 committed by GitHub
parent 56fe715bce
commit 6abdb0d593
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,7 +36,7 @@ trait TRichText
"%(([A-z]++):\/\/(\S*?\.\S*?))([\s)\[\]{},\"\'<]|\.\s|$)%",
(function (array $matches): string {
$href = str_replace("#", "&num;", $matches[1]);
$href = rawurlencode(str_replace(";", "&#59;", $matches[1]));
$href = rawurlencode(str_replace(";", "&#59;", $href));
$link = str_replace("#", "&num;", $matches[3]);
$link = str_replace(";", "&#59;", $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", "<EFBFBD>", $text);
return preg_replace("%\p{M}{3,}%Xu", "", $text);
}
function resolveMentions(array $skipUsers = []): \Traversable