From bdc511a4dce1539b664a64b079f3d8f58c7e5aba Mon Sep 17 00:00:00 2001 From: Rasmus Schmidt Date: Mon, 12 Aug 2024 17:05:13 +0200 Subject: [PATCH] refactor: remove url encoding for guzzle uri implementation --- Classes/Converter/Mailto2HrefObfuscatingConverter.php | 3 --- Classes/Fusion/ConvertEmailLinksImplementation.php | 5 +++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Classes/Converter/Mailto2HrefObfuscatingConverter.php b/Classes/Converter/Mailto2HrefObfuscatingConverter.php index 1eb2419..9468149 100644 --- a/Classes/Converter/Mailto2HrefObfuscatingConverter.php +++ b/Classes/Converter/Mailto2HrefObfuscatingConverter.php @@ -58,9 +58,6 @@ public function convert($mailAddress) */ protected function encryptEmail(string $string, int $randomOffset): string { - // Decode HTML entities to ensure & is not encoded as & - $string = html_entity_decode($string, ENT_QUOTES | ENT_HTML5); - $out = ''; // like str_rot13() but with a variable offset and a wider character range $len = strlen($string); diff --git a/Classes/Fusion/ConvertEmailLinksImplementation.php b/Classes/Fusion/ConvertEmailLinksImplementation.php index 5fdee90..f20b8aa 100644 --- a/Classes/Fusion/ConvertEmailLinksImplementation.php +++ b/Classes/Fusion/ConvertEmailLinksImplementation.php @@ -119,9 +119,10 @@ public function convertLinkName(array $matches) */ public function convertMailLink($matches) { - $email = trim($matches[2]); + $email = html_entity_decode(trim($matches[2]), ENT_QUOTES | ENT_HTML5); $replacedHrefContent = $this->mailToHrefConverter->convert($email); - return $matches[1] . htmlspecialchars($replacedHrefContent); + $uri = new \GuzzleHttp\Psr7\Uri($replacedHrefContent); + return $matches[1] . (string)$uri; } }