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

[cleanupIDs] symbol is incorrectly removed when its ID is only used by URL-encoded reference #1696

Closed
ctrlcctrlv opened this issue Sep 23, 2022 · 0 comments · Fixed by #1880
Labels

Comments

@ctrlcctrlv
Copy link

ctrlcctrlv commented Sep 23, 2022

Describe the bug
symbol is incorrectly removed when its ID is only used by URL-encoded reference.

Example files: https://gist.github.com/ctrlcctrlv/a985bd9fdf31ecc7e414ab29d49576ae

To Reproduce
Steps to reproduce the behavior:

svgo --config svgo.config.js -i working.svg -o working_o.svg
svgo --config svgo.config.js -i broken.svg -o broken_o.svg

Observe missing elements:
image

Expected behavior
No elements to be missing:
image

Desktop (please complete the following information):

  • SVGO Version 2.7.0
  • NodeJs Version v12.22.9
  • OS: Pop! OS 22.04

Code issue

You cannot just do a basic string comparison on hyperlink references. This will never work how its implementor intended.

Direct git blame is to:

const regReferencesHref = /^#(.+?)$/;

By @TrySound.

However this bug dates back to original implementation of the plugin, making it ten years old. 40ab776 by @deepsweet.

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.

1 participant