Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.2.0 'Cannot read properties of undefined' error in reflectPoint #1926

Closed
benjaminion opened this issue Jan 5, 2024 · 1 comment · Fixed by #1927
Closed

v3.2.0 'Cannot read properties of undefined' error in reflectPoint #1926

benjaminion opened this issue Jan 5, 2024 · 1 comment · Fixed by #1927
Labels

Comments

@benjaminion
Copy link

Describe the bug

In version 3.2.0 svgo fails on certain files with the following error when using the convertPathData plugin. The issue does not occur in v3.1.0 and earlier.

/tmp/node_modules/svgo/plugins/convertPathData.js:1160
  return [2 * base[0] - controlPoint[0], 2 * base[1] - controlPoint[1]];
                                    ^

TypeError: Cannot read properties of undefined (reading '0')
    at reflectPoint (/tmp/node_modules/svgo/plugins/convertPathData.js:1160:37)
    at /tmp/node_modules/svgo/plugins/convertPathData.js:802:43
    at Array.filter (<anonymous>)
    at filters (/tmp/node_modules/svgo/plugins/convertPathData.js:397:15)
    at Object.enter (/tmp/node_modules/svgo/plugins/convertPathData.js:183:20)
    at visit (/tmp/node_modules/svgo/lib/xast.js:52:30)
    at visit (/tmp/node_modules/svgo/lib/xast.js:68:9)
    at visit (/tmp/node_modules/svgo/lib/xast.js:68:9)
    at visit (/tmp/node_modules/svgo/lib/xast.js:68:9)
    at visit (/tmp/node_modules/svgo/lib/xast.js:68:9)

Node.js v20.6.1

An example file that triggers the error - the file validates with no issues.

To Reproduce
Run the following with the above file as input:

const svgo = require('svgo')
const fs = require('fs')

const originalSvg = fs.readFileSync('hysteresis.svg', 'utf8')
const svg = svgo.optimize(
  originalSvg,
  {
    plugins: ['convertPathData']
  }
)

Expected behavior
No errors.

Desktop (please complete the following information):

  • SVGO Version: 3.2.0
  • NodeJs Version 20.6.1
  • OS: Ubuntu 22.04.3 LTS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants