TYPO3 v7 RTE Rich text editor: Disallow tags and attributes

raw

README.rst

Warning: In TYPO3 v8, there are no default allowTags anymore. You have to define them yourself.

https://docs.typo3.org/typo3cms/extensions/core/8.7/Changelog/8.0/Breaking-72870-RemovedRTETransformationTs_preserveAndPreserveTags.html

raw

rte.ts

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Put this into Page TSConfig
 
# Rich Text Editor configuration
# https://docs.typo3.org/typo3cms/extensions/rtehtmlarea/Configuration/PageTsconfig/interfaceConfiguration/Index.html
# https://docs.typo3.org/typo3cms/CoreApiReference/Rte/Transformations/Index.html
# https://docs.typo3.org/typo3cms/TyposcriptReference/Functions/Htmlparser/Index.html
 
RTE.default {
    showButtons = bold, strong, emphasis, italic, unorderedlist, link, unlink, chMode
    RTEHeightOverride = 300
 
    proc {
        # allowTags gets added to the built-in list, so we use denyTags
        # default allowtags:
        #  a,b,blockquote,br,center,div,em,font,hr,i,img,li,ol,p,pre,span,strike,strong,sub,sup,u,ul
        denyTags = blockquote, center, div, font, h1, h2, h3, h4, h5, h6, hr, img, ol, pre, span, strike, sub, sup, strike, u
 
        entryHTMLparser_db = 1
        entryHTMLparser_db {
            removeTags < RTE.default.proc.denyTags
            noAttrib = b, br, div, em, i, li, p, strong, ul
            tags >
            # prevent activation of RteHtmlParser::transformStyledATags()
            tags.a.allowedAttribs = href,title,target
        }
    }
}
 
raw

test.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<html>
 <body>
  <h1>Style attributes</h1>
  <hr />
 
  <a style="color: red">a link</a>
  <b style="color: red">b bold</b>
  <i style="color: red">i italic</i>
  <strong style="color: red">strong bold</strong>
  <em style="color: red">em italic</em>
 
  <h1 style="color: red">h1 heading</h1>
  <h2 style="color: red">h2 heading</h2>
  <h3 style="color: red">h3 heading</h3>
  <h4 style="color: red">h4 heading</h4>
  <h5 style="color: red">h5 heading</h5>
  <h6 style="color: red">h6 heading</h6>
 
  <div style="color: red">div container</div>
 
  <p style="color: red">p paragraph</p>
 
  <ol style="color: red">
   <li style="color: red">ol ordered list with li list item</li>
  </ol>
  <ul style="color: red">
   <li style="color: red">ul unordered list with li list item</li>
  </ul>
 
 </body>
</html>
 
Christian Weiske Christian Weiske
owner

History