'htmlpurifier - How to escape self closing tags?
I have noticed that when passing html string to htmlpurifier, it replaces all self closing tags either by open and closing tags or by just open tags
example
Before purifying
<p>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mmultiscripts>
<mi>y</mi>
<mprescripts/>
<none/>
<mn>2</mn>
</mmultiscripts>
</math>
</p>
After purifying
<p>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mmultiscripts>
<mi>y</mi>
<mprescripts></mprescripts>
<none>
<mn>2</mn>
</mmultiscripts>
</math>
</p>
As you see the <none/> tag was replace after purifying by <none> tag Which destroyed the render of the html !
What to add in my configurations file in order to escape self closing tag? Is there any shorthand from this list can solve the problem ?
Please note that I am using htmlpurifier through mews/purifier package which is a package specific for laravel integration.
Solution 1:[1]
I believe the Empty rule for the <none> tag may point to why the closing tag disappears. HTML Empty tags, like <br>, <hr> and <img>, self-close implicitly. But you may be able to use an Inline element with a Custom rule for allowed children that's an empty regex.
Is the 'open and closing tags' scenario a problem for you? I'm not familiar enough with MathML to know whether this isn't just a cosmetic change; if the semantic behaviour of that code remains the same, I wouldn't worry about it. I don't currently know how to solve that one.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | pinkgothic |
