[!!!][TASK] Drop RTE config skipAlign and skipClass 28/47728/5
authorBenni Mack <benni@typo3.org>
Sat, 16 Apr 2016 10:36:18 +0000 (12:36 +0200)
committerNicole Cordes <typo3@cordes.co>
Fri, 6 May 2016 08:31:21 +0000 (10:31 +0200)
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 <typo3@wouterwolters.nl>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
typo3/sysext/core/Classes/Html/RteHtmlParser.php
typo3/sysext/core/Documentation/Changelog/master/Breaking-75710-RTE-relatedTSconfigOptionsSkipAlignAndSkipClassRemoved.rst [new file with mode: 0644]
typo3/sysext/rtehtmlarea/Configuration/PageTSconfig/Proc/pageTSConfig.txt

index ca7a146..337187c 100644 (file)
@@ -951,13 +951,8 @@ class RteHtmlParser extends HtmlParser
     {
         // Setting configuration for processing:
         $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);
-        // 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
         if (count($divSplit) <= 1 || $count <= 0) {
             // Wrap hr tags with LF's
@@ -966,6 +961,14 @@ class RteHtmlParser extends HtmlParser
             $newValue = preg_replace('/(^' . LF . ')|(' . LF . '$)/i', '', $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:
         foreach ($divSplit as $k => $v) {
             if ($k % 2) {
@@ -990,25 +993,15 @@ class RteHtmlParser extends HtmlParser
                         list($tagAttributes) = $this->get_tag_attributes($fTag);
                         // Keep attributes (lowercase)
                         $newAttribs = array();
-                        if (!empty($keepAttribListArr)) {
-                            foreach ($keepAttribListArr as $keepA) {
+                        if (!empty($allowedAttributesForParagraphTags)) {
+                            foreach ($allowedAttributesForParagraphTags as $keepA) {
                                 if (isset($tagAttributes[$keepA])) {
                                     $newAttribs[$keepA] = $tagAttributes[$keepA];
                                 }
                             }
-                        }
-                        // ALIGN attribute:
-                        if (!$this->procOptions['skipAlign'] && trim($tagAttributes['align']) !== '' && strtolower($tagAttributes['align']) != 'left') {
-                            // 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);
+                            // CLASS attribute - sort out the allowed tags
+                            if (trim($newAttribs['class']) !== '' && !empty($this->allowedClasses) && !in_array($newAttribs['class'], $this->allowedClasses)) {
+                                $classes = GeneralUtility::trimExplode(' ', $newAttribs['class'], true);
                                 $newClasses = array();
                                 foreach ($classes as $class) {
                                     if (in_array($class, $this->allowedClasses)) {
@@ -1017,6 +1010,8 @@ class RteHtmlParser extends HtmlParser
                                 }
                                 if (!empty($newClasses)) {
                                     $newAttribs['class'] = implode(' ', $newClasses);
+                                } else {
+                                    unset($newAttribs['class']);
                                 }
                             }
                         }
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-75710-RTE-relatedTSconfigOptionsSkipAlignAndSkipClassRemoved.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-75710-RTE-relatedTSconfigOptionsSkipAlignAndSkipClassRemoved.rst
new file mode 100644 (file)
index 0000000..675829c
--- /dev/null
@@ -0,0 +1,31 @@
+===============================================================================
+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
index f2760cf..4de7951 100644 (file)
@@ -37,10 +37,7 @@ RTE.default.proc {
        denyTags >
 
                ## ALLOWED P ATTRIBUTES
-               ## Attributes class and align are always preserved
-               ## 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
+       keepPDIVattribs = class, align, id, title, dir, lang, xml:lang, itemscope, itemtype, itemprop
 
                ## REMAP BOLD AND ITALIC TO STRONG AND EMPHASIS AND VICE VERSA
        transformBoldAndItalicTags = 1