-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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 svg parsing in case it uses empty use tag or use with image href #7044
Fix svg parsing in case it uses empty use tag or use with image href #7044
Conversation
5db9ca9
to
fd9726a
Compare
xlinkAttribute = el.getAttribute('xlink:href') || el.getAttribute('href'); | ||
|
||
if (xlinkAttribute === null) { | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this function returning on the others return early case? are we safe returning undefined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no explicit returns are there in the following code, so it's safe
edit for clarity:
There are no other return statements in parseUseDirectives
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only usage here (src/parser.js
):
fabric.parseSVGDocument = function(doc, callback, reviver, parsingOptions) {
if (!doc) {
return;
}
parseUseDirectives(doc);
..........
..........
..........
For checks:
|
@asturur All good from your side? |
Sorry i have been away |
So to clarify my question, the first time i looked at the PR i must have opened to much diff lines or to few, and i was seeing some other returns, but i see i was watching something else. Pr looks good, i m merging it. Next time try to avoid unnecessary format changes, however they may look better, they create non necessary diff changes to look at. Unless is a specific linting PR. |
sure, will keep in mind. thanks |
Fix cases where parsing string to svg was crashing.
Added the two test cases where this occurs.
1st case (empty ) occurs because xLinkAttribute is null (line 476)
2nd case (image href) occurs because element.parentNode is null
Didn't bump dist files as i'm not aware if this should be done in scope of PRs or not