Commit 492063b4 authored by Benni Mack's avatar Benni Mack Committed by Nicole Cordes
Browse files

[!!!][TASK] Drop RTE config skipAlign and skipClass

The two options to define whether to not allow align or class
attributes on <p> tags when converting from RTE to the DB
are dropped in favor of using keepPDIVattribs and adding them there
by default.

Resolves: #75710
Releases: master
Change-Id: Ie981a3f15f02f81c9721e2ee9421e183319f5b90
Reviewed-on: https://review.typo3.org/47728


Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Reviewed-by: Frank Nägler's avatarFrank Naegler <frank.naegler@typo3.org>
Reviewed-by: default avatarDaniel Goerz <ervaude@gmail.com>
Reviewed-by: Nicole Cordes's avatarNicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes's avatarNicole Cordes <typo3@cordes.co>
parent 7c28e6c7
...@@ -951,13 +951,8 @@ class RteHtmlParser extends HtmlParser ...@@ -951,13 +951,8 @@ class RteHtmlParser extends HtmlParser
{ {
// Setting configuration for processing: // Setting configuration for processing:
$allowTagsOutside = GeneralUtility::trimExplode(',', strtolower($this->procOptions['allowTagsOutside'] ? 'hr,' . $this->procOptions['allowTagsOutside'] : 'hr,img'), true); $allowTagsOutside = GeneralUtility::trimExplode(',', strtolower($this->procOptions['allowTagsOutside'] ? 'hr,' . $this->procOptions['allowTagsOutside'] : 'hr,img'), true);
// Setting the third param will eliminate false end-tags. Maybe this is a good thing to do...?
$divSplit = $this->splitIntoBlock('p', $value, true); $divSplit = $this->splitIntoBlock('p', $value, true);
// Setting the third param to 1 will eliminate false end-tags. Maybe this is a good thing to do...?
if ($this->procOptions['keepPDIVattribs']) {
$keepAttribListArr = GeneralUtility::trimExplode(',', strtolower($this->procOptions['keepPDIVattribs']), true);
} else {
$keepAttribListArr = array();
}
// Returns plainly the value if there was no div/p sections in it // Returns plainly the value if there was no div/p sections in it
if (count($divSplit) <= 1 || $count <= 0) { if (count($divSplit) <= 1 || $count <= 0) {
// Wrap hr tags with LF's // Wrap hr tags with LF's
...@@ -966,6 +961,14 @@ class RteHtmlParser extends HtmlParser ...@@ -966,6 +961,14 @@ class RteHtmlParser extends HtmlParser
$newValue = preg_replace('/(^' . LF . ')|(' . LF . '$)/i', '', $newValue); $newValue = preg_replace('/(^' . LF . ')|(' . LF . '$)/i', '', $newValue);
return $newValue; return $newValue;
} }
// define which attributes are allowed on <p> tags
if ($this->procOptions['keepPDIVattribs']) {
$allowedAttributesForParagraphTags = GeneralUtility::trimExplode(',', strtolower($this->procOptions['keepPDIVattribs']), true);
} else {
$allowedAttributesForParagraphTags = array();
}
// Traverse the splitted sections: // Traverse the splitted sections:
foreach ($divSplit as $k => $v) { foreach ($divSplit as $k => $v) {
if ($k % 2) { if ($k % 2) {
...@@ -990,25 +993,15 @@ class RteHtmlParser extends HtmlParser ...@@ -990,25 +993,15 @@ class RteHtmlParser extends HtmlParser
list($tagAttributes) = $this->get_tag_attributes($fTag); list($tagAttributes) = $this->get_tag_attributes($fTag);
// Keep attributes (lowercase) // Keep attributes (lowercase)
$newAttribs = array(); $newAttribs = array();
if (!empty($keepAttribListArr)) { if (!empty($allowedAttributesForParagraphTags)) {
foreach ($keepAttribListArr as $keepA) { foreach ($allowedAttributesForParagraphTags as $keepA) {
if (isset($tagAttributes[$keepA])) { if (isset($tagAttributes[$keepA])) {
$newAttribs[$keepA] = $tagAttributes[$keepA]; $newAttribs[$keepA] = $tagAttributes[$keepA];
} }
} }
} // CLASS attribute - sort out the allowed tags
// ALIGN attribute: if (trim($newAttribs['class']) !== '' && !empty($this->allowedClasses) && !in_array($newAttribs['class'], $this->allowedClasses)) {
if (!$this->procOptions['skipAlign'] && trim($tagAttributes['align']) !== '' && strtolower($tagAttributes['align']) != 'left') { $classes = GeneralUtility::trimExplode(' ', $newAttribs['class'], true);
// Set to value, but not 'left'
$newAttribs['align'] = strtolower($tagAttributes['align']);
}
// CLASS attribute:
// Set to whatever value
if (!$this->procOptions['skipClass'] && trim($tagAttributes['class']) !== '') {
if (empty($this->allowedClasses) || in_array($tagAttributes['class'], $this->allowedClasses)) {
$newAttribs['class'] = $tagAttributes['class'];
} else {
$classes = GeneralUtility::trimExplode(' ', $tagAttributes['class'], true);
$newClasses = array(); $newClasses = array();
foreach ($classes as $class) { foreach ($classes as $class) {
if (in_array($class, $this->allowedClasses)) { if (in_array($class, $this->allowedClasses)) {
...@@ -1017,6 +1010,8 @@ class RteHtmlParser extends HtmlParser ...@@ -1017,6 +1010,8 @@ class RteHtmlParser extends HtmlParser
} }
if (!empty($newClasses)) { if (!empty($newClasses)) {
$newAttribs['class'] = implode(' ', $newClasses); $newAttribs['class'] = implode(' ', $newClasses);
} else {
unset($newAttribs['class']);
} }
} }
} }
......
===============================================================================
Breaking: #75710 - RTE-related TSconfig options skipAlign and skipClass removed
===============================================================================
Description
===========
The two RTE-related TSconfig options :ts:`RTE.default.proc.skipAlign` and :ts:`RTE.default.proc.skipClass`
that don't allow align and class attributes when converting content from the RTE to the database have been removed.
Impact
======
Setting these options will have no effect anymore.
Affected Installations
======================
Any installation setting custom TSconfig options for :ts:`skipAlign`, :ts:`skipClass` or setting
:ts:`keepPDIVattribs` without :ts:`class` and :ts:`align` as values are affected.
Migration
=========
In order to allow class and align attributes in paragraph tags, the option :ts:`keepPDIVattribs`
needs to be extended to also include "class" and "align" as values, which is done by default.
If an installation has custom TSconfig settings using :ts:`keepPDIVattribs`, the two attributes needs to be added
accordingly to still allow class and align attributes to be kept when transforming from the RTE to the database.
\ No newline at end of file
...@@ -37,10 +37,7 @@ RTE.default.proc { ...@@ -37,10 +37,7 @@ RTE.default.proc {
denyTags > denyTags >
## ALLOWED P ATTRIBUTES ## ALLOWED P ATTRIBUTES
## Attributes class and align are always preserved keepPDIVattribs = class, align, id, title, dir, lang, xml:lang, itemscope, itemtype, itemprop
## Align attribute will be unset on entry (see below)
## This is a list of additional attributes to keep
keepPDIVattribs = id, title, dir, lang, xml:lang, itemscope, itemtype, itemprop
## REMAP BOLD AND ITALIC TO STRONG AND EMPHASIS AND VICE VERSA ## REMAP BOLD AND ITALIC TO STRONG AND EMPHASIS AND VICE VERSA
transformBoldAndItalicTags = 1 transformBoldAndItalicTags = 1
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment