diff --git a/typo3/sysext/core/Classes/DataHandling/DataHandler.php b/typo3/sysext/core/Classes/DataHandling/DataHandler.php index 2f048ec4f67f04f80fee0492cdb599c4491b71eb..4f1c83dfac0bd6e80982f2c9343ebf27def5f1ed 100644 --- a/typo3/sysext/core/Classes/DataHandling/DataHandler.php +++ b/typo3/sysext/core/Classes/DataHandling/DataHandler.php @@ -1565,7 +1565,6 @@ class DataHandler // Initialize transformation: $parseHTML = GeneralUtility::makeInstance(RteHtmlParser::class); $parseHTML->init($table . ':' . $field, $pid); - $parseHTML->setRelPath(''); // Perform transformation: $value = $parseHTML->RTE_transform($value, $defaultExtras, 'db', $thisConfig); } diff --git a/typo3/sysext/core/Classes/Html/RteHtmlParser.php b/typo3/sysext/core/Classes/Html/RteHtmlParser.php index 09190c8131a09b69127b9fbc02cb117199723c33..bb27d18fbccf3c8633ebb7161c0644ba4b5882de 100644 --- a/typo3/sysext/core/Classes/Html/RteHtmlParser.php +++ b/typo3/sysext/core/Classes/Html/RteHtmlParser.php @@ -46,20 +46,6 @@ class RteHtmlParser extends \TYPO3\CMS\Core\Html\HtmlParser */ public $elRef = ''; - /** - * Relative path - * - * @var string - */ - public $relPath = ''; - - /** - * Relative back-path - * - * @var string - */ - public $relBackPath = ''; - /** * Current Page TSConfig * @@ -122,30 +108,6 @@ class RteHtmlParser extends \TYPO3\CMS\Core\Html\HtmlParser $this->elRef = $elRef; } - /** - * Setting the ->relPath and ->relBackPath to proper values so absolute references to links and images can be converted to relative dittos. - * This is used when editing files with the RTE - * - * @param string $path The relative path from PATH_site to the place where the file being edited is. Eg. "fileadmin/static". - * @return void There is no output, it is set in internal variables. With the above example of "fileadmin/static" as input this will yield ->relPath to be "fileadmin/static/" and ->relBackPath to be "../../ - * @TODO: Check if relPath and relBackPath are used for anything useful after removal of "static file edit" with #63818 - */ - public function setRelPath($path) - { - $path = trim($path); - $path = preg_replace('/^\\//', '', $path); - $path = preg_replace('/\\/$/', '', $path); - if ($path) { - $this->relPath = $path; - $this->relBackPath = ''; - $partsC = count(explode('/', $path)); - for ($a = 0; $a < $partsC; $a++) { - $this->relBackPath .= '../'; - } - $this->relPath .= '/'; - } - } - /********************************************** * * Main function @@ -450,7 +412,7 @@ class RteHtmlParser extends \TYPO3\CMS\Core\Html\HtmlParser } // Convert absolute to relative url if (GeneralUtility::isFirstPartOfStr($attribArray['src'], $siteUrl)) { - $attribArray['src'] = $this->relBackPath . substr($attribArray['src'], strlen($siteUrl)); + $attribArray['src'] = substr($attribArray['src'], strlen($siteUrl)); } $imgSplit[$k] = '<img ' . GeneralUtility::implodeAttributes($attribArray, 1, 1) . ' />'; } @@ -482,7 +444,6 @@ class RteHtmlParser extends \TYPO3\CMS\Core\Html\HtmlParser $absoluteUrl = trim($attribArray['src']); // Transform the src attribute into an absolute url, if it not already if (strtolower(substr($absoluteUrl, 0, 4)) !== 'http') { - $attribArray['src'] = substr($attribArray['src'], strlen($this->relBackPath)); // If site is in a subpath (eg. /~user_jim/) this path needs to be removed because it will be added with $siteUrl $attribArray['src'] = preg_replace('#^' . preg_quote($sitePath, '#') . '#', '', $attribArray['src']); $attribArray['src'] = $siteUrl . $attribArray['src']; @@ -523,7 +484,7 @@ class RteHtmlParser extends \TYPO3\CMS\Core\Html\HtmlParser list($attribArray) = $this->get_tag_attributes($this->getFirstTag($v), true); // If the url is local, remove url-prefix if ($siteURL && substr($attribArray['href'], 0, strlen($siteURL)) == $siteURL) { - $attribArray['href'] = $this->relBackPath . substr($attribArray['href'], strlen($siteURL)); + $attribArray['href'] = substr($attribArray['href'], strlen($siteURL)); } $bTag = '<a ' . GeneralUtility::implodeAttributes($attribArray, 1) . '>'; $eTag = '</a>'; @@ -614,7 +575,7 @@ class RteHtmlParser extends \TYPO3\CMS\Core\Html\HtmlParser $siteURL = $this->siteUrl(); // If the url is local, remove url-prefix if ($siteURL && substr($attribArray['href'], 0, strlen($siteURL)) == $siteURL) { - $attribArray['href'] = $this->relBackPath . substr($attribArray['href'], strlen($siteURL)); + $attribArray['href'] = substr($attribArray['href'], strlen($siteURL)); } // Check for FAL link-handler keyword list($linkHandlerKeyword, $linkHandlerValue) = explode(':', $attribArray['href'], 2); @@ -1530,7 +1491,7 @@ class RteHtmlParser extends \TYPO3\CMS\Core\Html\HtmlParser if ($attribArray['href'] !== '') { $uP = parse_url(strtolower($attribArray['href'])); if (!$uP['scheme']) { - $attribArray['href'] = $this->siteUrl() . substr($attribArray['href'], strlen($this->relBackPath)); + $attribArray['href'] = $this->siteUrl() . $attribArray['href']; } elseif ($uP['scheme'] != 'mailto') { $attribArray['data-htmlarea-external'] = 1; } diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-72666-RTERemoveRelativePathCalculations.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-72666-RTERemoveRelativePathCalculations.rst new file mode 100644 index 0000000000000000000000000000000000000000..d3a3f3cc5928ed05ce5f24d6824b10a81b5a5b1a --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Breaking-72666-RTERemoveRelativePathCalculations.rst @@ -0,0 +1,21 @@ +========================================================= +Breaking: #72666 - RTE: Remove relative path calculations +========================================================= + +Description +=========== + +Since the removal of the feature editing static files with the Rich Text Editor (option "static_file_edit"), the path calculations for files +within the HtmlParser including the method ``RteHtmlParser->setRelPath()`` were removed as well. + + +Impact +====== + +Using the method ``RteHtmlParser->setRelPath()`` will result in a fatal PHP error. + + +Affected Installations +====================== + +Any installations with custom RTE transformations that use a custom implementation of the RteHtmlParser PHP class. \ No newline at end of file diff --git a/typo3/sysext/rtehtmlarea/Classes/Form/Element/RichTextElement.php b/typo3/sysext/rtehtmlarea/Classes/Form/Element/RichTextElement.php index 4f13d8c7b9193aedffd2965c0d18e7c732d2ecec..bc499ff0c0910fb62a97df397f739b13b2c4d959 100644 --- a/typo3/sysext/rtehtmlarea/Classes/Form/Element/RichTextElement.php +++ b/typo3/sysext/rtehtmlarea/Classes/Form/Element/RichTextElement.php @@ -1303,7 +1303,6 @@ class RichTextElement extends AbstractFormElement /** @var RteHtmlParser $parseHTML */ $parseHTML = GeneralUtility::makeInstance(RteHtmlParser::class); $parseHTML->init($this->data['table'] . ':' . $this->data['fieldName'], $this->pidOfVersionedMotherRecord); - $parseHTML->setRelPath(''); $value = $parseHTML->RTE_transform($value, $this->defaultExtras, 'rte', $this->processedRteConfiguration); } }