How to prevent richtext component from stripping off script tags? | Community
Skip to main content
Level 3
October 16, 2015
Solved

How to prevent richtext component from stripping off script tags?

  • October 16, 2015
  • 8 replies
  • 3524 views

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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Sham_HC

Overlay WhitespaceProcessor.js & HtmlSerializer.js

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

8 replies

Sham_HC
Sham_HCAccepted solution
Level 10
October 16, 2015

Overlay WhitespaceProcessor.js & HtmlSerializer.js

  • In WhitespaceProcessor in tagname remove script
  • At  HtmlSerializer modify the method serializeTextNode to return  dom.nodeValue without replace
smacdonald2008
Level 10
October 16, 2015
Level 3
October 16, 2015

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?

Level 3
October 16, 2015

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.

Level 3
October 16, 2015

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

smacdonald2008
Level 10
October 16, 2015

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. 

Sham_HC
Level 10
October 16, 2015

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

Level 3
October 16, 2015

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