Purifier icon indicating copy to clipboard operation
Purifier copied to clipboard

How to escape special charcters?

Open omarelewa21 opened this issue 4 years ago • 0 comments

I am using a laravel html purifier package for purifying my rich text from any xss before storing in database.

But my rich text allows for Wiris symbols which uses special character as → or  .

Problem is the package does not allow me to escape these characters. It removes them completely. What should I do to escape them ??

Example of the string before purifying

<p><math xmlns="http://www.w3.org/1998/Math/MathML"><msup><mi>x</mi><mn>2</mn></msup><mo>&#160;</mo><mo>+</mo><mo>&#160;</mo><mmultiscripts><mi>y</mi><mprescripts/><none/><mn>2</mn></mmultiscripts><mo>&#160;</mo><mover><mo>&#8594;</mo><mo>=</mo></mover><mo>&#160;</mo><msup><mi>z</mi><mn>2</mn></msup><mo>&#160;</mo></math></p>

After purifying

<p><math xmlns="http://www.w3.org/1998/Math/MathML"><msup><mi>x</mi><mn>2</mn></msup><mo> </mo><mo>+</mo><mo> </mo><mmultiscripts><mi>y</mi><mprescripts></mprescripts><none><mn>2</mn></mmultiscripts><mo> </mo><mover><mo>→</mo><mo>=</mo></mover><mo> </mo><msup><mi>z</mi><mn>2</mn></msup><mo> </mo></math></p>

omarelewa21 avatar Apr 16 '22 04:04 omarelewa21