-
Notifications
You must be signed in to change notification settings - Fork 560
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
parsePattern crash #637
Comments
Hi, @kamil3, can you attach the correct SVG file? This file is actually broken. |
@amarunko - I don't have a sample svg I can post but there are certainly crashes in here. For example, in SVGParser parsePattern, this code executes: if let shape = try parseNode(pattern.children.first!) as? Shape { If that let fails then contentNode never gets set. Then it gets unwrapped with the crash operator on the return and blows up. return UserSpacePattern(content: contentNode!, bounds: bounds, userSpace: userSpace, contentUserSpace: contentUserSpace) (using 0.9.5) |
Sorry, but without example for debugging - it is very hard to find the reason, the place is known - it is better than nothing of course, but parsing depends on many styles, parent attributes, etc. |
The file in this zip shows the problem in my test code. |
Thank you very much, I will look deeper soon Sent with GitHawk |
Fixed here |
Merged PR which should fix this issue, so closing it. |
Fatal error: Unexpectedly found nil while unwrapping an Optional value: file (...)/Macaw-master/Source/svg/SVGParser.swift, line 402
I'm testing Macaw Example and I changed a default tiger image to my own SVG image. My SVG image contains pattern attribute. Both in a web browser and finder it renders fine.
Shortened contents of SVG:
<?xml version="1.0" encoding="UTF-8"?> <svg width="1600px" height="1600px" viewBox="0 0 1600 1600" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <!-- Generator: Sketch 54.1 (76490) - https://sketchapp.com --> <title>Test</title> <desc>Created with Sketch.</desc> <defs> <pattern id="pattern-1" patternUnits="objectBoundingBox" x="0%" width="100%" height="100%"> <use xlink:href="#image-2"></use> </pattern> <image id="image-2" width="1600" height="1600" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAB9AAAAfQCAIAAAAVWlMuAAAABGdBTUEAALGOfPtRkwAAAAlwSFlzAAAN1wAADdcBQiibeAAAQABJREF(...) </defs> <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> <g id="Artboard" transform="translate(-14698.000000, -14063.000000)" fill="url(#pattern-1)" stroke="#979797"> <g id="Test" transform="translate(14698.000000, 14063.000000)"> <path d="M0.5,0.5 L0.5,1599.5 L1599.5,1599.5 L1599.5,0.5 L0.5,0.5 Z M74.5,74.5 L1525.5,74.5 L1525.5,1525.5 L74.5,1525.5 L74.5,74.5 Z" id="Combined-Shape"></path> </g> </g> </g> </svg>
The text was updated successfully, but these errors were encountered: