From ba9d3657491ef4f84900650dd84423d7a6e0edd8 Mon Sep 17 00:00:00 2001
From: Benni Mack <benni@typo3.org>
Date: Tue, 20 Jun 2017 10:08:51 +0200
Subject: [PATCH] [BUGFIX] Ensure links with ampersands are HSC-decoded

Since the new link structure is in place with TYPO3 v8
all links are properly htmlspecialchar'ed in the database.

This means, that links with an ampersand are now encoded
and need to be decoded on output so ampersands are rendered
as "&" and not as "&amp;" in the frontend.

Resolves: #80985
Resolves: #81625
Releases: master, 8.7
Change-Id: I213f84453a721b97c3238662febe10d0fb5a9bf7
Reviewed-on: https://review.typo3.org/53268
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Thomas Hohn <thomas@hohn.dk>
Reviewed-by: Tobi Kretschmann <tobi@tobishome.de>
Tested-by: Tobi Kretschmann <tobi@tobishome.de>
Reviewed-by: Steffen Frese <steffenf14@gmail.com>
Tested-by: Steffen Frese <steffenf14@gmail.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 .../sysext/frontend/Classes/Typolink/ExternalUrlLinkBuilder.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/typo3/sysext/frontend/Classes/Typolink/ExternalUrlLinkBuilder.php b/typo3/sysext/frontend/Classes/Typolink/ExternalUrlLinkBuilder.php
index 46a45d855d8e..da20f1de3622 100644
--- a/typo3/sysext/frontend/Classes/Typolink/ExternalUrlLinkBuilder.php
+++ b/typo3/sysext/frontend/Classes/Typolink/ExternalUrlLinkBuilder.php
@@ -27,7 +27,7 @@ class ExternalUrlLinkBuilder extends AbstractTypolinkBuilder
     public function build(array &$linkDetails, string $linkText, string $target, array $conf): array
     {
         return [
-            $this->processUrl(UrlProcessorInterface::CONTEXT_EXTERNAL, $linkDetails['url'], $conf),
+            $this->processUrl(UrlProcessorInterface::CONTEXT_EXTERNAL, htmlspecialchars_decode($linkDetails['url']), $conf),
             $this->parseFallbackLinkTextIfLinkTextIsEmpty($linkText, $linkDetails['url']),
             $target ?: $this->resolveTargetAttribute($conf, 'extTarget', true, $this->getTypoScriptFrontendController()->extTarget)
         ];
-- 
GitLab