ARTICLE AD BOX
I am trying to santisize Rich Text coming as HTML from my frontend.
Using the following:
const res = purify.sanitize(inputHtml, { ALLOWED_TAGS: ['b', 'p', 'i', 'div', 'br', 'u', 'strike'] ALLOWED_ATTR: ['style'], });Here is an example output to all the functionality that I allow with this rich text editor
<div><b>Bold</b></div> <div><br></div> <div><u>Underline</u></div> <div><br></div> <div><i>Italic Text</i></div> <div><br></div> <div><strike>Strike</strike></div> <div><br></div> <div>Left</div> <div><br></div> <div style="text-align: center;">Middle</div> <div><br></div> <div style="text-align: right;">Right</div>Currently it will pass the sanitize check. But I want to also limit the allowed styles to only allow text-align, and so if user try to add color, it will be stripped.
I couldn't find a way to do so in the docs.
1,0452 gold badges8 silver badges22 bronze badges
