#92943RTE ckeditor does not respect YAML configuration
Description
Hello Core-Team,
the rte_ckeditor does not respect my YAML configuration. In following some examples.
The default value of bloclElementList is a comma separated list of HTML tags: “DIV,TABLE,BLOCKQUOTE,PRE,UL,OL,H1,H2,H3,H4,H5,H6,ADDRESS,DL,DD,HEADER,SECTION,FOOTER,NAV,ARTICLE,ASIDE”
I override these tags inside of YAML:
processing:
blockElementList:
- table
- blockquote
- ul
- ol
- h3
- h4
- h5
As we have YAML, these values will be converted into an array and will be processed by core that way:
$tags = array_unique(GeneralUtility::trimExplode(',', $tag, true));
Which results into $tags with a value of: [0 => “1”]
In case of “allowTagsOutside” it is working correct, as you check against “allowTagsOutside.”:
// Override tags which are allowed outside of <p> tags
if (isset($this->procOptions['allowTagsOutside'])) {
if (!isset($this->procOptions['allowTagsOutside.'])) {
$this->allowedTagsOutsideOfParagraphs = GeneralUtility::trimExplode(',', strtolower($this->procOptions['allowTagsOutside']), true);
} else {
$this->allowedTagsOutsideOfParagraphs = (array)$this->procOptions['allowTagsOutside.'];
}
}
In case of “allowAttribute” you only allow array. There is no check on string and no trimExplode on “,”:
// Define which attributes are allowed on <p> tags
if (isset($this->procOptions['allowAttributes.'])) {
$this->allowedAttributesForParagraphTags = $this->procOptions['allowAttributes.'];
}
Ok, another example
processing:
HTMLparser_db:
tags:
p:
fixAttrib:
style:
list:
- 'text-align: left;'
- 'text-align: right;'
This will be converted to an array, too. But this will break “range” and “list” processing as they expect a string value:
if ((string)$keepTags[$key]['fixAttrib'][$atName]['range'] !== '') {
$keepTags[$key]['fixAttrib'][$atName]['range'] = GeneralUtility::trimExplode(',', $keepTags[$key]['fixAttrib'][$atName]['range']);
}
if ((string)$keepTags[$key]['fixAttrib'][$atName]['list'] !== '') {
$keepTags[$key]['fixAttrib'][$atName]['list'] = GeneralUtility::trimExplode(',', $keepTags[$key]['fixAttrib'][$atName]['list']);
}
Either all values must be compatible with string AND array, or we should deliver a new example of TYPO3s default YAML files where all properties are declared as string only.
Stefan
Reviews 6
- main 74473[BUGFIX] Allow allowedAttribs HTMLParser as either string or array
- 13.4 88734[BUGFIX] Allow allowedAttribs HTMLParser as either string or array
- main 85137[BUGFIX] Read RTE options as string and array
- 13.4 88476[BUGFIX] Read RTE options as string and array
- 13.4 88414[TASK] Add tests for RteHtmlParser and HtmlParser YAML coverage
- main 88244[TASK] Add tests for RteHtmlParser and HtmlParser YAML coverage
Related issues 4
- Feature #87314allowedAttribs / allowAttributes usage in config
- Bug #87400CKEditor: assign correct CSS class to tags with entryHTMLparser_db
- Bug #97499Wrong notation for value of allowedAttribs in Processing.yaml
- Task #106189HtmlParser / RTE HTML Parser is missing YAML parse tests and array/string notation testing for fixAttribs
History 917
-
Stefan Froemken commented <span data-processor="relativetime" data-value="2020-11-27T13:44:46+00:00" > 11/27/20, 13:44 </span>
-
Benni Mack changed Related to #87400 <span data-processor="relativetime" data-value="2022-01-26T08:22:48+00:00" > 01/26/22, 08:22 </span>
-
Benni Mack changed Related to #87314 <span data-processor="relativetime" data-value="2022-01-26T08:22:56+00:00" > 01/26/22, 08:22 </span>
-
Eric Harrer changed Related to #97499 <span data-processor="relativetime" data-value="2022-04-29T13:55:34+00:00" > 04/29/22, 13:55 </span>
-
Stefan Froemken commented <span data-processor="relativetime" data-value="2024-07-05T20:16:13+00:00" > 07/05/24, 20:16 </span>
I have created my own Preset:
imports: - { resource: "EXT:rte_ckeditor/Configuration/RTE/Default.yaml" } processing: blockElementList: - table - blockquote - ul - ol - h3 - h4 - h5and activated it as new default (page TSconfig):
RTE.default.preset = sf
Just opening an content element with RTE results instant in following error:
Cannot assign int to property TYPO3\CMS\Core\Html\RteHtmlParser::$blockElementList of type string
convertPlainArrayToTypoScriptArray will result in
proc.blockElementList = 1 proc.blockElementList. = [ 0 => table, 1 => blockquote, 2 => ul, 3 => ol, 4 => h3, 5 => h4, 6 => h5, ]
As “1” is INT it will fail while assigning this value to class property “blockElementList” which is defined as string
-
Georg Ringer changed TYPO3 Version
1013 <span data-processor="relativetime" data-value="2024-07-05T20:50:59+00:00" > 07/05/24, 20:50 </span> -
Gerrit Code Review pushed patch set 1 for main to change 85137 status
NewUnder Review <span data-processor="relativetime" data-value="2024-07-05T21:52:01+00:00" > 07/05/24, 21:52 </span> -
Gerrit Code Review pushed patch set 2 for main to change 85137 <span data-processor="relativetime" data-value="2024-07-05T21:59:01+00:00" > 07/05/24, 21:59 </span>
-
Gerrit Code Review pushed patch set 3 for main to change 85137 <span data-processor="relativetime" data-value="2024-07-05T22:03:36+00:00" > 07/05/24, 22:03 </span>
-
Gerrit Code Review pushed patch set 4 for main to change 85137 <span data-processor="relativetime" data-value="2024-10-18T13:37:36+00:00" > 10/18/24, 13:37 </span>
-
Gerrit Code Review pushed patch set 5 for main to change 85137 <span data-processor="relativetime" data-value="2024-10-24T09:12:41+00:00" > 10/24/24, 09:12 </span>
-
Garvin Hicking changed Related to #106189 <span data-processor="relativetime" data-value="2025-02-17T16:37:42+00:00" > 02/17/25, 16:37 </span>
-
Gerrit Code Review pushed patch set 6 for main to change 85137 <span data-processor="relativetime" data-value="2025-02-28T19:40:37+00:00" > 02/28/25, 19:40 </span>
-
Gerrit Code Review pushed patch set 7 for main to change 85137 <span data-processor="relativetime" data-value="2025-02-28T19:57:07+00:00" > 02/28/25, 19:57 </span>
-
Gerrit Code Review pushed patch set 1 for 13.4 to change 88476 <span data-processor="relativetime" data-value="2025-03-04T11:30:05+00:00" > 03/04/25, 11:30 </span>
-
Stefan Froemken commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2025-03-04T13:05:07+00:00" > 03/04/25, 13:05 </span>Applied in changeset commit:37c0c62ee2d90284249cca54a681ae309b6b5ffa.
-
Benni Mack changed status
ResolvedClosed <span data-processor="relativetime" data-value="2025-08-12T14:35:31+00:00" > 08/12/25, 14:35 </span>
Same problem with “denyTags”:
$denyTags = GeneralUtility::trimExplode(',', $this->procOptions['denyTags'] ?? '', true);But in case of “allowTags” it works as you convert it back to comma separated list:
if (isset($this->procOptions['allowTags.']) && is_array($this->procOptions['allowTags.'])) { $keepTags = implode(',', $this->procOptions['allowTags.']); } else { $keepTags = $this->procOptions['allowTags'] ?? ''; } $keepTags = array_flip(GeneralUtility::trimExplode(',', $this->defaultAllowedTagsList . ',' . strtolower($keepTags), true));