Project

General

Profile

Actions

Bug #73675

closed

URLs with spaces in the RTE

Added by Marco Huber about 8 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2016-02-25
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

Sometimes there could be spaces in a link inserted in the RTE, f.e. if you link to a local file (file:///C:\my\Path is\sö\crazy with everything.pdf) as external URL. Then there should be wrapped some " around the url part of the typo3 link tag, like it is already done in all other link fields (f.e. the field header_link). Otherwise, when the link tag is parsed, some parts of the URL are used as target, class and title.

In \TYPO3\CMS\Core\Html\RteHtmlParser::TS_links_db() we should use the function TypoLinkCodecService::encode().
IMO the cleanest solution would be:

@@ -595,9 +595,6 @@ class RteHtmlParser extends \TYPO3\CMS\Core\Html\HtmlParser
                 }
                 // Only if href, target, class and tile are the only attributes, we can alter the link!
                 if (empty($attribArray_copy)) {
-                    // Quoting class and title attributes if they contain spaces
-                    $attribArray['class'] = preg_match('/ /', $attribArray['class']) ? '"' . $attribArray['class'] . '"' : $attribArray['class'];
-                    $attribArray['title'] = preg_match('/ /', $attribArray['title']) ? '"' . $attribArray['title'] . '"' : $attribArray['title'];
                     // Creating the TYPO3 pseudo-tag "<LINK>" for the link (includes href/url, target and class attributes):
                     // If data-htmlarea-external attribute is set, keep the href unchanged
                     if ($attribArray['data-htmlarea-external']) {
@@ -605,7 +602,8 @@ class RteHtmlParser extends \TYPO3\CMS\Core\Html\HtmlParser
                     } else {
                         $href = $info['url'] . ($info['query'] ? ',0,' . $info['query'] : '');
                     }
-                    $bTag = '<link ' . $href . ($attribArray['target'] ? ' ' . $attribArray['target'] : ($attribArray['class'] || $attribArray['title'] ? ' -' : '')) . ($attribArray['class'] ? ' ' . $attribArray['class'] : ($attribArray['title'] ? ' -' : '')) . ($attribArray['title'] ? ' ' . $attribArray['title'] : '') . '>';
+                    $typoLink = GeneralUtility::makeInstance(TypoLinkCodecService::class)->encode(array('url' => $href, 'target' => $attribArray['target'], 'class' => $attribArray['class'], 'title' => $attribArray['title'], 'additionalParams' => ''));
+                    $bTag = '<link ' . $typoLink . '>';
                     $eTag = '</link>';
                     // Modify parameters
                     if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_parsehtml_proc.php']['modifyParams_LinksDb_PostProc']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_parsehtml_proc.php']['modifyParams_LinksDb_PostProc'])) {


But this would be a breaking change, because we change the value of $attribArray['title'] and $attribArray['class'] in the hook $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_parsehtml_proc.php']['modifyParams_LinksDb_PostProc'].
So that's why I remove the " from $attribArray['title'] and $attribArray['class'] manually in my patch.

Actions

Also available in: Atom PDF