This is treated as a XSS vulnerability issue. I'm using the redactor component from Imperavi, and it seems like it can't generate the right output value when the Html is not valid.
The problem is when we insert strings like this:
<<SCRIPT a=2>qssQ5GkdwWU=7;//<</SCRIPT>
The redactor removes the script tags and generates this string. This is expected because of XSS attacks.
<qssQ5GkdwWU=7;//<
The problem happens then the redactor tries to set the previous value to the redactor element using html.(html). It will think that there is an element and will output this:
<qssq5gkdwwu=7;> </qssq5gkdwwu=7;>
How can I set the value to the element but preventing this behavior?
You can override JQuery's
htmlPrefilterfunction:If special character are the issue then try escaping them like this:
Execute above script preferably before you load Redactor.
If you decide to do your own sanitization then you could use DOMPurify or similar library.
First image gets red border. And because of the sanitization second doesn't.