fskpf/svg2roughjs

Path data errors must result in the element being rendered up until the error

ygra opened this issue · 1 comments

ygra commented

E.g. the following image has an error in its path data:

https://raw.githubusercontent.com/edent/SuperTinyIcons/master/images/svg/linux_mint.svg

<svg xmlns="http://www.w3.org/2000/svg"
aria-label="Linux Mint" role="img"
viewBox="0 0 512 512"><filter id="b"><feGaussianBlur stdDeviation="3"/></filter><linearGradient id="g"><stop stop-color="#c7f994" offset="0"/><stop stop-color="#87cf3e" offset="1"/></linearGradient><use href="#p" filter="url(#b)" opacity=".5"/><g fill="#fff"><path id="p" d="M59.6 97.5v100h40v101a121 121 0 00120 120h198v-201a121 121 0 00-120-120z"/></g><path fill="url(#g)" d="M83.6 122.2v51.3h13.3a25 25 0 0124 24v94.9c-.3 55.9 46.7 101.4 101.5 101.5H365c13.9-.1 25-11.4 25-25V224c.3-56-46.7-101.5-101.6-101.7H83.6z"/><path d="MM83.6 122.2v51.3h13.3a25 25 0 0124 24v94.9c-.3 55.9 46.7 101.4 101.5 101.5H365c13.9-.1 25 -11.4 25 -25V224c0.3-56 -46.7 -101.5 -101.6 -101.7H83.6z" opacity=".1" filter="url(#b)"/><g fill="none" stroke="#fff" stroke-width="32"><path d="M160 144v160a48 48 0 0048 48h32m112-48v-80a32 32 0 00-64 0v80m0-80a32 32 0 00-64 0v80"/><path d="M240 352h64a48 48 0 0048-48" opacity=".5"/></g></svg>

(Note the double M at the start of one of the paths)

The expectation is that everything else is rendered and that single path is not (since the error occurs right at the start).

fskpf commented

I don't think we should fix this here. It's rather a missing feature of the svg-pathdata dependency: nfroidure/svg-pathdata#48

Anyhow, I think we should catch errors during the element processing, otherwise rendering entirely stops e.g. for bad input on a specific element.