Compare commits

...

2 commits

Author SHA1 Message Date
celestora
6abdb0d593
Further improvements to TRichText
Fix link parsing + remove zalgo completely
2023-02-25 18:08:17 +02:00
celestora
56fe715bce
Fix ';' error in posts 2023-02-25 18:07:29 +02:00

View file

@ -36,9 +36,9 @@ trait TRichText
"%(([A-z]++):\/\/(\S*?\.\S*?))([\s)\[\]{},\"\'<]|\.\s|$)%", "%(([A-z]++):\/\/(\S*?\.\S*?))([\s)\[\]{},\"\'<]|\.\s|$)%",
(function (array $matches): string { (function (array $matches): string {
$href = str_replace("#", "&num;", $matches[1]); $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("#", "&num;", $matches[3]);
$link = str_replace(";", "&#59;", $matches[3]); $link = str_replace(";", "&#59;", $link);
$rel = $this->isAd() ? "sponsored" : "ugc"; $rel = $this->isAd() ? "sponsored" : "ugc";
return "<a href='/away.php?to=$href' rel='$rel' target='_blank'>$link</a>" . htmlentities($matches[4]); return "<a href='/away.php?to=$href' rel='$rel' target='_blank'>$link</a>" . htmlentities($matches[4]);
@ -49,7 +49,7 @@ trait TRichText
private function removeZalgo(string $text): string 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 function resolveMentions(array $skipUsers = []): \Traversable