svg / svgo

⚙️ Node.js tool for optimizing SVG files
https://svgo.dev/
MIT License
20.82k stars 1.38k forks source link

SVGO 3 does not understand numbered HTML entities #1713

Closed iessa-pragg-ctct closed 1 week ago

iessa-pragg-ctct commented 1 year ago

Describe the bug Running SVGO 3.0.2 on an asset that contains a numbered HTML entity (&) causes a syntax parsing error. Replacing the numbered entity with its equivalent named version works &.

SvgoParserError: .\i_ASSET_Pg2.svg:8400:57: Invalid character in entity name

  8398 | …<g id="shape498-2264" v:mID="498" v:groupContext="shape" v:layerMember="4" tr…
  8399 | …      <title>Sheet.498</title>
> 8400 | …      <desc>DIAGRAM – SCHEMATIC, BOB, MACHINE, DX, DA &#38; DAA T4F GGG, GEN 3...</…
       |                                                            ^
  8401 | …      <v:textBlock v:margins="rect(4,4,4,4)" v:tabSpace="42.5197" v:verticalAlign=…
  8402 | …      <v:textRect cx="219.471" cy="765.117" width="438.95" height="53.7668" />

To Reproduce Steps to reproduce the behavior:

  1. Create an SVG <svg><text>Foo &#38; Bar</text></svg>
  2. Run SVGO 3 on it
  3. See error

Expected behavior SVGO should handle numbered HTML entities.

Extra Info This problem does not occur with SVGO 2

Desktop (please complete the following information):

johnkenny54 commented 3 weeks ago

This still fails in version 3.3.2, looks like it is fixed in v4.

SethFalco commented 1 week ago

Indeed, that has been addressed in main, which is the current release candidate.

If you want to use it now, you can do use v4.0.0-rc.0, or wait for it to be the official release!