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

StackOverflowException when SVG contains image with href #436

Closed
AnReZa opened this issue Apr 18, 2019 · 6 comments · Fixed by #449
Closed

StackOverflowException when SVG contains image with href #436

AnReZa opened this issue Apr 18, 2019 · 6 comments · Fixed by #449

Comments

@AnReZa
Copy link

AnReZa commented Apr 18, 2019

I want to render the following SVG using this library. However, this will throw a StackOverflowException. When I delete the image tag, it works:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" id="ap-canvas" class="bg-raster" version="1.1">
    <image xlink:href="http://localhost:51124/Diagnosis/LK-1808081/Photos/7" data-bind="attr: { 'xlink:href': modeData.imgSrc, href: modeData.imgSrc }" x="0" y="0" width="100%" height="100%" href="http://localhost:51124/Diagnosis/LK-1808081/Photos/7" />
    <defs id="SvgjsDefs1006" />
    <rect id="SvgjsRect1008" width="313" height="448" stroke-opacity="1" stroke="#ff0d28" stroke-width="3" fill-opacity="1" fill="rgba(0, 0, 0, 0)" x="360" y="48" />
</svg>
public MemoryStream RenderAs(ImageFormat imgFormat = null) {
    try {
        string s = Shape.Replace(@"""/Diagnosis/", @"""http://localhost:51124/Diagnosis/");

        SvgDocument svg = SvgDocument.FromSvg<SvgDocument>(s);
        Bitmap bitmap = svg.Draw();
        MemoryStream ms = new MemoryStream();

        //bitmap.Save(ms, imgFormat ?? ImageFormat.Jpeg);

        bitmap.Save(@"C:\test\test.jpg", imgFormat ?? ImageFormat.Jpeg);

        return ms;
    } catch(Exception ex) {
        throw ex;
    }
}

Is this a bug, or am I doing something wrong here?

@AnReZa
Copy link
Author

AnReZa commented Apr 18, 2019

I realized, that it has something to do with the width="100%" and height="100%" settings. When I replace them with absolute units for testing purposes, it works. Is there a way to fix that?

@AnReZa
Copy link
Author

AnReZa commented May 7, 2019

Have anyone had the chance to reproduce this issue? It's kind of a breaking issue, because you cannot catch the StackOverflowException. It will crash your software anyways, even if you put a try catch block around it.

@mrbean-bremen
Copy link
Member

I could reproduce this, but last time I checked, I didn't really understand the problem. I will have another go sometime this week.

mrbean-bremen added a commit to mrbean-bremen/SVG that referenced this issue May 8, 2019
mrbean-bremen added a commit to mrbean-bremen/SVG that referenced this issue May 9, 2019
mrbean-bremen added a commit that referenced this issue May 9, 2019
@AnReZa
Copy link
Author

AnReZa commented May 13, 2019

@mrbean-bremen Do you think, that it would make sense to make a hotfix release out of that?

@mrbean-bremen
Copy link
Member

I think it makes sense to wait a few days until possible problems with the .NET Core addition are settled.

@AnReZa
Copy link
Author

AnReZa commented May 13, 2019

Sure, it's not urgent. ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants