svgcleaner icon indicating copy to clipboard operation
svgcleaner copied to clipboard

Hangs when valid svg with --multipass

Open NoNoNo opened this issue 4 years ago • 4 comments

svgcleaner hangs on invalid svg, when invoked with option --multipass:

$ /Applications/SVGCleaner.app/Contents/MacOS/svgcleaner-cli --version
svgcleaner 0.9.5
echo '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M0 0h512v512H0z"/>id=&quot;defs4976&quot; /&gt;<path d="M60.81 476.91h300v-60h-300v60zm233.79-347.3l13.94 7.39c31.88-43.62 61.34-31.85 61.34-31.85l-21.62 53 35.64 19 2.87 33 64.42 108.75-43.55 29.37s-26.82-36.39-39.65-43.66c-10.66-6-41.22-10.25-56.17-12l-67.54-76.91-12 10.56 37.15 42.31c-.13.18-.25.37-.38.57-35.78 58.17 23 105.69 68.49 131.78H84.14C93 85 294.6 129.61 294.6 129.61z" fill="#fff"/></svg>' | \
/Applications/SVGCleaner.app/Contents/MacOS/svgcleaner-cli --multipass --stdout -

Note the id=&quot;defs4976&quot; /&gt; portion in the svg.

NoNoNo avatar Jan 19 '20 12:01 NoNoNo

@NoNoNo Your file 209.svg.txt

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
 <path d="M0 0h512v512H0z"/>
 id=&quot;defs4976&quot; /&gt;
 <path d="M60.81 476.91h300v-60h-300v60zm233.79-347.3l13.94 7.39c31.88-43.62 61.34-31.85 61.34-31.85l-21.62 53 35.64 19 2.87 33 64.42 108.75-43.55 29.37s-26.82-36.39-39.65-43.66c-10.66-6-41.22-10.25-56.17-12l-67.54-76.91-12 10.56 37.15 42.31c-.13.18-.25.37-.38.57-35.78 58.17 23 105.69 68.49 131.78H84.14C93 85 294.6 129.61 294.6 129.61z" fill="#fff"/>
</svg>

is xml-invalid, you can check that via https://validator.w3.org/

JoKalliauer avatar Jan 23 '20 22:01 JoKalliauer

Even worse…

NoNoNo avatar Jan 29 '20 15:01 NoNoNo

@NoNoNo I think no optimizer supports invalid SVG, therefore I expect your suggestion will be declined. Do you want a proper Errormessage, or what is your suggestion?

JoKalliauer avatar Jan 30 '20 09:01 JoKalliauer

Well, this is definitely a bug. Even if a file is malformed is should not hand the application.

RazrFalcon avatar Jan 30 '20 10:01 RazrFalcon