Giter VIP home page Giter VIP logo

Specific SVG causes SVGO to fail: TypeError: Cannot read properties of undefined (reading '0') Edit: Bug is worse than I thought, SVGO corrupts all SVGs before encountering the invalid SVG. about svgo HOT 3 OPEN

futuremotiondev avatar futuremotiondev commented on July 28, 2024
Specific SVG causes SVGO to fail: TypeError: Cannot read properties of undefined (reading '0') Edit: Bug is worse than I thought, SVGO corrupts all SVGs before encountering the invalid SVG.

from svgo.

Comments (3)

futuremotiondev avatar futuremotiondev commented on July 28, 2024

Update to this issue. The severity is much higher than I thought.

I found another SVG causing SVGO to fail, but the terrible part is when I process a folder of SVGs that also contains the "bad" SVG using svgo -r -f 'C:\Icons\SomeFolderWithSVGs\', SVGO deletes all data from valid SVGs up until it reaches the "bad" SVG. So it's corrupting completely valid SVGs and causing data loss.

Here is a zip file of SVGs:

Microsoft Docons.zip

The "bad" SVG in this collection is brand-instagram-65369.svg

  1. Extract the zip somewhere, I.E. C:\Microsoft Docons\
  2. Open a terminal and enter svgo -r -f 'C:\Microsoft Docons\'
  3. You should see the same error I pasted in my first post.
  4. Open C:\Microsoft Docons\, and observe that these (valid) SVGs are now empty files:
.notdef-1114112.svg
arrow-down-65312.svg
arrow-down8-61614.svg
arrow-left-65313.svg
arrow-right-65305.svg
arrow-swap-65392.svg
arrow-up-left-65304.svg
arrow-up-right-61545.svg
arrow-up8-61613.svg
asterisk-59960.svg
asterisk-solid-62285.svg
backpack-65413.svg
blog-61995.svg
book-art64-61204.svg
book-open-65382.svg
book-solid-65365.svg
brand-dev-to-65368.svg
brand-facebook-65300.svg
brand-github-65302.svg

Definitely a pretty nasty bug. Having SVGO choke on a file is one thing, but corrupting other valid files is pretty awful.

Hopefully there is a resolution to this.

from svgo.

KTibow avatar KTibow commented on July 28, 2024

SVGO deletes all data from valid SVGs

I believe this is due to how Node handles the priority of events and stuff.

Cannot read properties of undefined (reading '0')

Duplicate of #1926, also see comments on #1927

from svgo.

futuremotiondev avatar futuremotiondev commented on July 28, 2024

SVGO deletes all data from valid SVGs

I believe this is due to how Node handles the priority of events and stuff.

Can you elaborate on this? Is there any way to mitigate this behavior? I can't safely use SVGO in production if there is a chance that somewhere in the pipeline valid data gets wiped out.

Cannot read properties of undefined (reading '0')

Duplicate of #1926, also see comments on #1927

Read the comments, glad to hear a fix is in the works.

from svgo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.