Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

How to prevent richtext component from stripping off script tags?

Avatar

Level 3

After update from CQ 5.5 to AEM 5.6.1 we are facing situation when richtext component is stripping <script /> tags entered via "HTML source" mode. What is the preferred way of configuring this behavior?

1 Accepted Solution

Avatar

Correct answer by
Level 10

Overlay WhitespaceProcessor.js & HtmlSerializer.js

  • In WhitespaceProcessor in tagname remove script
  • At  HtmlSerializer modify the method serializeTextNode to return  dom.nodeValue without replace

View solution in original post

8 Replies

Avatar

Correct answer by
Level 10

Overlay WhitespaceProcessor.js & HtmlSerializer.js

  • In WhitespaceProcessor in tagname remove script
  • At  HtmlSerializer modify the method serializeTextNode to return  dom.nodeValue without replace

Avatar

Level 3

Hi Sham,

There are two WhitespaceProcessor.js files in AEM 5.6.1:

  • /etc/clientlibs/granite/coralui/optional/rte/js/core/WhitespaceProcessor.js from rte.coralui clientlib
  • /libs/cq/ui/rte/core/WhitespaceProcessor.js from cq.rte

It seems that first one is for Touch UI and second is for Classic UI and I have to overlay them both, correct? In that case how I can overlay /etc/clientlibs file? It's pretty straightforward how to overlay files under /libs, but what about /etc?

Avatar

Level 3

I've seen that and it isn't the same. It was about one very specific element - ID attribute in HTML tags. I need to find a way how to configure Ext in AEM to avoid stripping off arbitrary tags, not just ID attributes.

Avatar

Level 3

smacdonald2008 wrote...

Here is a similar issue:

https://forums.adobe.com/thread/1019650

 

It's not the same, I need to prevent stripping off HTML tags, not just ID attribute

Avatar

Level 10

See the RTE Reference docs:

http://dev.day.com/docs/en/cq/current/widgets-api/index.html?class=CQ.form.RichText

See: stripHtmlTags. Set this to false. See if that helps. 

Avatar

Level 10

jura.khrapunov wrote...

Hi Sham,

There are two WhitespaceProcessor.js files in AEM 5.6.1:

  • /etc/clientlibs/granite/coralui/optional/rte/js/core/WhitespaceProcessor.js from rte.coralui clientlib
  • /libs/cq/ui/rte/core/WhitespaceProcessor.js from cq.rte

It seems that first one is for Touch UI and second is for Classic UI and I have to overlay them both, correct? In that case how I can overlay /etc/clientlibs file? It's pretty straightforward how to overlay files under /libs, but what about /etc?

 

You are right etc cannot be overlayed.  However 5.6.1 coral has not complete ready so you can ignore & I tested only for classic ui.

[1]  http://www.aemstuff.com/#article970

Avatar

Level 3

smacdonald2008 wrote...

See the RTE Reference docs:

http://dev.day.com/docs/en/cq/current/widgets-api/index.html?class=CQ.form.RichText

See: stripHtmlTags. Set this to false. See if that helps. 

 

This one has no effect for the code typed in in the HTML source edit mode in richtext editor component. It only affects copy/pasted text and, according to the docs, already deprecated