darylldoyle / svg-sanitizer

A PHP SVG/XML Sanitizer
GNU General Public License v2.0
454 stars 67 forks source link

Is it possible to preserve white spaces? #107

Open mrmacete opened 3 days ago

mrmacete commented 3 days ago

Apparently all white spaces are lost at parse time because of this:

https://github.com/darylldoyle/svg-sanitizer/blob/master/src/Sanitizer.php#L105

$this->xmlDocument->preserveWhiteSpace = false;

is this vital to sanitisation or does it make sense to have it configurable (or even true by default) ?

there are legit SVG files, like the ones produced by the freeze tool [0] which rely on white spaces to properly format textual content sampled from terminals, and would be great to support them all the way down to WordPress sanitisation, as those are great for technical blogposts!

[0] https://github.com/charmbracelet/freeze/tree/main