[BUGFIX] Allow arbitrary protocols in new LinkService 84/52684/2
authorBenni Mack <benni@typo3.org>
Wed, 26 Apr 2017 18:40:21 +0000 (20:40 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Tue, 2 May 2017 18:03:23 +0000 (20:03 +0200)
Since TYPO3 v8 it is not possible to simply create a link to "tel:+491727144385" anymore,
which was possible in TYPO3 v7. Instead an exception is thrown as the "toString()" method
cannot handle legacy links which have no specific type.

The patch checks for a "url" attribute allowing to represent a URL and to render a link via typolink.

Resolves: #80217
Releases: master, 8.7
Change-Id: I617e280295b4789a8c295f5ee21463a643e58afc
Reviewed-on: https://review.typo3.org/52684
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/core/Classes/LinkHandling/LegacyLinkNotationConverter.php
typo3/sysext/core/Classes/LinkHandling/LinkService.php
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php

index 6b822c2..a89b678 100644 (file)
@@ -69,12 +69,11 @@ class LegacyLinkNotationConverter
             // Check for link-handler keyword
             list($linkHandlerKeyword, $linkHandlerValue) = explode(':', $linkParameter, 2);
             $result['type'] = strtolower(trim($linkHandlerKeyword));
-            $result['url'] = $linkHandlerValue;
+            $result['url'] = $linkParameter;
+            $result['value'] = $linkHandlerValue;
             if ($result['type'] === LinkService::TYPE_RECORD) {
                 list($a['identifier'], $a['table'], $a['uid']) = explode(':', $linkHandlerValue);
                 $result['url'] = $a;
-            } else {
-                // @TODO add a hook for old typolinkLinkHandler to convert their values properly, forge #79647
             }
         } else {
             // special handling without a scheme
index 8b6ef7f..5a525e0 100644 (file)
@@ -146,6 +146,10 @@ class LinkService implements SingletonInterface
     {
         if (is_object($this->handlers[$parameters['type']])) {
             return $this->handlers[$parameters['type']]->asString($parameters);
+        } elseif (isset($parameters['url']) && !empty($parameters['url'])) {
+            // This usually happens for tel: or other types where a URL is available and the
+            // legacy link service could resolve at least something
+            return $parameters['url'];
         }
         throw new Exception\UnknownLinkHandlerException('No valid handlers found for type: ' . $parameters['type'], 1460629247);
     }
index 88d396b..1072939 100644 (file)
@@ -5603,7 +5603,7 @@ class ContentObjectRenderer
         $linkService = GeneralUtility::makeInstance(LinkService::class);
         $linkDetails = $linkService->resolve($linkParameter);
         $linkDetails['typoLinkParameter'] = $linkParameter;
-        if (isset($GLOBALS['TYPO3_CONF_VARS']['FE']['typolinkBuilder'][$linkDetails['type']])) {
+        if (isset($linkDetails['type']) && isset($GLOBALS['TYPO3_CONF_VARS']['FE']['typolinkBuilder'][$linkDetails['type']])) {
             /** @var AbstractTypolinkBuilder $linkBuilder */
             $linkBuilder = GeneralUtility::makeInstance(
                 $GLOBALS['TYPO3_CONF_VARS']['FE']['typolinkBuilder'][$linkDetails['type']],
@@ -5615,6 +5615,8 @@ class ContentObjectRenderer
                 // Only return the link text directly
                 return $e->getLinkText();
             }
+        } elseif (isset($linkDetails['url'])) {
+            $this->lastTypoLinkUrl = $linkDetails['url'];
         } else {
             return $linkText;
         }