diff --git a/typo3/sysext/core/Classes/Html/HtmlParser.php b/typo3/sysext/core/Classes/Html/HtmlParser.php index 3cf654b3065a5c5f23f5ae45fce35e0b5502f769..286af109133e3b45891cd8aff8bf4b37071ade26 100644 --- a/typo3/sysext/core/Classes/Html/HtmlParser.php +++ b/typo3/sysext/core/Classes/Html/HtmlParser.php @@ -40,13 +40,13 @@ class HtmlParser /** * Returns an array with the $content divided by tag-blocks specified with the list of tags, $tag * Even numbers in the array are outside the blocks, Odd numbers are block-content. - * Use ->getAllParts() and ->removeFirstAndLastTag() to process the content if needed. + * Use ->removeFirstAndLastTag() to process the content if needed. * * @param string $tag List of tags, comma separated. * @param string $content HTML-content * @param bool $eliminateExtraEndTags If set, excessive end tags are ignored - you should probably set this in most cases. * @return array Even numbers in the array are outside the blocks, Odd numbers are block-content. - * @see splitTags(), getAllParts(), removeFirstAndLastTag() + * @see splitTags(), removeFirstAndLastTag() */ public function splitIntoBlock($tag, $content, $eliminateExtraEndTags = false) { @@ -147,12 +147,12 @@ class HtmlParser /** * Returns an array with the $content divided by tag-blocks specified with the list of tags, $tag * Even numbers in the array are outside the blocks, Odd numbers are block-content. - * Use ->getAllParts() and ->removeFirstAndLastTag() to process the content if needed. + * Use ->removeFirstAndLastTag() to process the content if needed. * * @param string $tag List of tags * @param string $content HTML-content * @return array Even numbers in the array are outside the blocks, Odd numbers are block-content. - * @see splitIntoBlock(), getAllParts(), removeFirstAndLastTag() + * @see splitIntoBlock(), removeFirstAndLastTag() */ public function splitTags($tag, $content) { @@ -182,28 +182,6 @@ class HtmlParser return $newParts; } - /** - * Returns an array with either tag or non-tag content of the result from ->splitIntoBlock()/->splitTags() - * Does not include the tags in the tag parts. - * - * @param array $parts Parts generated by ->splitIntoBlock() or >splitTags() - * @param bool $tag_parts Whether to return the tag-parts (default,TRUE) or what was outside the tags. - * @return array Tag-parts/Non-tag-parts depending on input argument settings - * @see splitIntoBlock(), splitTags() - * @private Currently only use to remove content from table cells inside RteHtmlParser - */ - public function getAllParts($parts, $tag_parts = true) - { - $newParts = array(); - foreach ($parts as $k => $v) { - if (($k + ($tag_parts ? 0 : 1)) % 2) { - $v = $this->removeFirstAndLastTag($v); - $newParts[] = $v; - } - } - return $newParts; - } - /** * Removes the first and last tag in the string * Anything before the first and after the last tags respectively is also removed diff --git a/typo3/sysext/core/Classes/Html/RteHtmlParser.php b/typo3/sysext/core/Classes/Html/RteHtmlParser.php index bb27d18fbccf3c8633ebb7161c0644ba4b5882de..6813e626389d13781a35535419e5028f94ea9219 100644 --- a/typo3/sysext/core/Classes/Html/RteHtmlParser.php +++ b/typo3/sysext/core/Classes/Html/RteHtmlParser.php @@ -840,15 +840,8 @@ class RteHtmlParser extends \TYPO3\CMS\Core\Html\HtmlParser break; case 'ol': case 'ul': - if ($css) { - $blockSplit[$k] = preg_replace(('/[' . LF . CR . ']+/'), ' ', $this->transformStyledATags($blockSplit[$k])) . $lastBR; - } - break; case 'table': - // Tables are NOT allowed in any form (unless preserveTables is set or CSS is the mode) - if (!$this->procOptions['preserveTables'] && !$css) { - $blockSplit[$k] = $this->TS_transform_db($this->removeTables($blockSplit[$k])); - } else { + if ($css) { $blockSplit[$k] = preg_replace(('/[' . LF . CR . ']+/'), ' ', $this->transformStyledATags($blockSplit[$k])) . $lastBR; } break; @@ -1321,37 +1314,6 @@ class RteHtmlParser extends \TYPO3\CMS\Core\Html\HtmlParser return GeneralUtility::getIndpEnv('TYPO3_SITE_URL'); } - /** - * Remove all tables from incoming code - * The function is trying to do this in a more or less respectful way. The approach is to resolve each table cells content and implode it all by <br /> chars. Thus at least the content is preserved in some way. - * - * @param string $value Input value - * @param string $breakChar Break character to use for linebreaks. - * @return string Output value - */ - public function removeTables($value, $breakChar = '<br />') - { - // Splitting value into table blocks: - $tableSplit = $this->splitIntoBlock('table', $value); - // Traverse blocks of tables: - foreach ($tableSplit as $k => $v) { - if ($k % 2) { - $tableSplit[$k] = ''; - $rowSplit = $this->splitIntoBlock('tr', $v); - foreach ($rowSplit as $k2 => $v2) { - if ($k2 % 2) { - $cellSplit = $this->getAllParts($this->splitIntoBlock('td', $v2)); - foreach ($cellSplit as $k3 => $v3) { - $tableSplit[$k] .= $v3 . $breakChar; - } - } - } - } - } - // Implode it all again: - return implode($breakChar, $tableSplit); - } - /** * Default tag mapping for TS * diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-72783-RemovedRTETransformationOptionPreserveTables.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-72783-RemovedRTETransformationOptionPreserveTables.rst new file mode 100644 index 0000000000000000000000000000000000000000..06ef996fc05d74274ddbbc92a5004cb65c682a9a --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Breaking-72783-RemovedRTETransformationOptionPreserveTables.rst @@ -0,0 +1,32 @@ +=================================================================== +Breaking: #72783 - Removed RTE transformation option preserveTables +=================================================================== + +Description +=========== + +The RTE transformation option "preserveTables" that allowed keeping HTML table tags and their contents is removed. + +Additionally, the methods ``RteHtmlParser->removeTables`` and ``HtmlParser->getAllParts`` are removed +without substitution. + + +Impact +====== + +When the RTE is configured to use ``overruleMode = ts`` instead of the default "ts_css" the option ``RTE.default.proc.preserveTables = 1`` will have no effect anymore. + +Calling ``RteHtmlParser->removeTables`` or ``HtmlParser->getAllParts`` inside a custom extension will result in a fatal PHP error. + + +Affected Installations +====================== + +Any TYPO3 instance with a legacy-mode (overruleMode = ts) from TYPO3 3.x or an extension doing custom transformations by using ``RteHtmlParser->removeTables``. + + +Migration +========= + +Use the overruleMode ``ts_css`` instead which keeps the tables as they are. If tables should be disallowed inside the RTE +the option ``RTE.default.proc.denyTags := addToList(table)`` can be used instead. \ No newline at end of file