Transformations are directives for parsing HTML markup. They are executed by the
TYPO3 Core every time a RTE-based field is saved to the TYPO3 database or fetched
from the database for the Rich Text Editor to render. This way, there are always
two ways / two transformations applied.
There are several advantages for transformations, the most prominent reason is to
not inject bad HTML code into the database which in turn would be used for output.
Transformations from the RTE towards the database can filter out HTML tags or attributes.
A Brief Dive Into History
Back in the very old days of TYPO3, there was an RTE which only worked inside Microsoft
Internet Explorer 4 (within the system extension “rte
”). All other editors of TYPO3 had
to write HTML by hand, which was very complicated with all the table-based layouts available.
Links were not set with a
<a>
tag, but with a so-called
<typolink 23,13 _blank>
tag. Further tags were
<typolist>
and
<typohead>
, which were stored in the database
1:1. Since RTEs did not understand these special tags, they had to transform these special tags into
valid HTML tags. Additionally, TYPO3 did not store regular
<p>
or
<div>
tags but
treated every line without a surrounding HTML block element as
<p>
tag. The frontend rendering
then added <p>
tags for each line when parsing (see below).
Transformations were later used to allow
<em>
/
<strong>
tags instead of
<b>
/
<i>
tags, while staying backwards-compatible.
A lot of transformation options have been dropped for TYPO3 v8, and the default configuration
for these transformations acts as a solid base. CKEditor itself includes features that work as
another security layer for disallowing injecting of certain HTML tags in the database.
For TYPO3 v8, the
<typolink>
tag was migrated to proper
<a>
tags with a special
<a href="t3://page?id=23">
syntax when linking to pages to ensure HTML valid output.
Additionally, all records that are edited and stored to the database now contain proper
<p> tags, and transformations for paragraph tags are only applied when not set yet.
Transformations for invalid links and images (still available in HtmlArea) are still in place.
Most logic related to transformations can be found within
\TYPO3\CMS\Core\Html\RteHtmlParser
.
Transformations vs. CKEditor’s Advanced Content Filter
TYPO3’s HtmlParser transformations were used to transform readable semi-HTML
code to a full-blown HTML rendering ready for the RTE and vice versa. Since
TYPO3 v8, magically adding
<p>
tags or transforming
<typolink>
tags is not necessary anymore, which leaves transformations almost obsolete.
However, they can act as an extra fallback layer of security to filter out
disallowed tags when saving. TYPO3 v8 configuration ships with a generic
transformation configuration, which is mainly based on legacy functionality
shipped with TYPO3 nowadays.
However, CKEditor comes with a separate strategy of allowing which HTML tags
and attributes are allowed, and can be configured on an editor-level.
This configuration option is called “allowedContent”, the feature itself is
named Advanced Content Filter
(ACF).
Activating CKEditor’s table plugin allows to add
<table>
,
<tr>
tags etc. Enabling the link picker enables the usage of
<a>
tags. CKEditor
cleans content right away which was e.g. copy-pasted from MS Word and does not
match the allowed tags.