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

fix(parser): Skip id attribute from normalization #10079

Merged
merged 3 commits into from
Aug 26, 2024

Conversation

miroljub1995
Copy link
Contributor

Description

If we load SVG that has some object with id attribute starting with a number, we get a wrong id parsed.

Copy link

codesandbox bot commented Aug 19, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@miroljub1995 miroljub1995 changed the title Skip id attribute from normalization fix(parser): Skip id attribute from normalization Aug 19, 2024
@zhe-he
Copy link
Contributor

zhe-he commented Aug 21, 2024

This kind of attribute has issues as well, right?
<svg data-custom-attribute="123abc"></svg>

attr === 'xlink:href' ||
attr === 'font' ||
attr === 'id'
) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function is a bit weird.
We do carry a parse and and outputValue around and in some cases we just do an early return.
Hopefully there is a better way to fix it. All the attributes that start with a number that are not specially taken care of here are going to be wrong correct?
So any custom attribute will need to be listed here and that is not really feasible

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it better to explicitly specify which one needs to be normalized?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

somehow this function become really convoluted yesterday i tried to look at it to expedite this fix. Eventually we can just fix as you did and open a ticket for a refactor, i didn't decide it yet sorry.

@asturur
Copy link
Member

asturur commented Aug 25, 2024

@miroljub1995 add this line to the changelog:
fix(SVGImport): Allow parsing of 'id' attribute that starts with a number #10079

and we can merge.

Please check that it gets formatted as the other lines or we get a lint error.
I can't edit myself as i don't have write access to your branch

@miroljub1995
Copy link
Contributor Author

@asturur

  • I added line to CHANGELOG
  • Regarding to lint, I checked with npm run prettier:check && npm run lint, but there are already some errors so I just checked if no new errors are on files I changed.

@asturur
Copy link
Member

asturur commented Aug 26, 2024

There are maybe warnings, the checkmark is green.
Or maybe somehow you are picking up a different configuration

@asturur asturur merged commit 03c426f into fabricjs:master Aug 26, 2024
18 of 20 checks passed
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants