Parsing error with xmlns:x specified
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- objective-c
- Domain
- computer-graphics, mobile-dev
Research direction
Reproduce the provided SVG and start in SVGSVGElement:postProcessAttributesAddingErrorsTo, then inspect NamedNodeMap:getNamedItem where the x attribute is selected. Confirm namespace-qualified attributes do not cause the SVG x value to resolve to the xmlns:x URL, and add a regression test or verification for successful parsing without the reported fatal conversion error.
Written by the indexing model from the issue text.
Description
New Issue Checklist
- I have read and understood the CONTRIBUTING guide
- I have reproduced the problem while running in Xcode, and read the Console log, and acted upon any relevant error or warning messages
- I have reproduced the problem while running in Xcode's Debugger, and used breakpoints to examine the actual values of variables vs the expected values
- I am not using CocoaPods, or: I am using CocoaPods, but have verified my podspec points to SVGKit v2.x
Issue Description and Steps
When parsing the following SVG (only relevant part copied below)
<?xml version="1.0"?>
<svg xmlns:x="http://ns.adobe.com/Extensibility/1.0/" xmlns:i="http://ns.adobe.com/AdobeIllustrator/10.0/" xmlns:graph="http://ns.adobe.com/Graphs/1.0/" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="Layer_1" x="0px" y="0px" width="1440px" height="1440px" viewBox="0 0 1440 1440" xml:space="preserve">
</svg>
the resulting UIImage is nil. This is due to the fact that in SVGSVGElement:postProcessAttributesAddingErrorsTo the x position is parsed incorrectly. The returned NSString from this call:
NSString* pos_x = [self getAttribute:@"x"]; is http://ns.adobe.com/Extensibility/1.0/ and not 0px. I verified that in NamedNodeMap:getNamedItem there are three dictionaries one for https://www.w3.org/2000/xmIns/ and another one for https://www.w3.org/2000/svg. Only the latter contains the correct x value. However since https://www.w3.org/2000/xmIns/ is the first item in the list its x value is retrieved and then parsing this string to a number fails with the following error:
Printing description of self->parseErrorsAndWarnings:
[Parse result: 0 warnings, 0 errors(recoverable), 1 errors (fatal). First fatal error: Error Domain=SVGK Parsing Code=32523432 "Exception = Asked to convert a (19) value to a (5) (couldn't find a valid conversion route). Float (4 d.p.) = 0.0000, String = http://ns.adobe.com/Extensibility/1.0/" UserInfo={NSLocalizedDescription=Exception = Asked to convert a (19) value to a (5) (couldn't find a valid conversion route). Float (4 d.p.) = 0.0000, String = http://ns.adobe.com/Extensibility/1.0/}
I am wondering: is this a bug in the library or is the SVG not correctly authored. Anyway there might be a better solution to this instead of bailing out. I am happy to hear your thoughts.
Kind regards,
David
PS: I attached a screenshots of the debugger displaying the problem.
- Dominant language
- Objective-C
- Stars
- 4.6k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from SVGKit/SVGKit
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Releases Open
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
name collision Open
Difficulty 2/5 1-3 hours Newbie friendliness 25/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
noah-nuebling/mac-mouse-fix#2054 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
obsproject/obs-studio#13918 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
SwiftOldDriver/iOS-Weekly#5439 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100