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

SVGs do not support file:// scheme on mac #1485

Closed
mike-marcacci opened this issue Dec 1, 2018 · 5 comments
Closed

SVGs do not support file:// scheme on mac #1485

mike-marcacci opened this issue Dec 1, 2018 · 5 comments
Labels

Comments

@mike-marcacci
Copy link

It appears that the precompiled binaries for mac don't include the ability for SVGs to reference local files. Here is a simple test which fails to draw the red circle on darwin, but succeeds on linux-x64.

  • run.sh will run the tests
  • run-in-docker.sh will run them on linux in docker

Note that the "absolute path" tests assume the directory is at /workspace.

test.zip

@lovell
Copy link
Owner

lovell commented Dec 2, 2018

Hello, did you see the librsvg docs?

"When processing an SVG, librsvg will only load referenced files if they are in the same directory as the base file, or in a subdirectory of it... This is so that malicious SVG files cannot include files that are in a directory above."

https://developer.gnome.org/rsvg/2.45/rsvg-RsvgHandle.html#id-1.2.4.5.4

The test-no-scheme-relative.svg file takes the correct approach.

The librsvg internals use g_file_get_uri to calculate the current directory of the SVG file. That logic will differ slightly between platforms, so perhaps it's producing file://... on Linux hence those test cases working on that platform.

@lovell lovell added the question label Dec 2, 2018
@mike-marcacci
Copy link
Author

mike-marcacci commented Dec 2, 2018

Hi there - I did, I actually read through all the relevant source in librsvg and libvips. The only reason I have a tests without a scheme and with relative paths is because that’s how they’re done in the test suite on librsvg; likewise the reason I use the file:// scheme is because I noticed it was explicitly checked (albeit on a normalized version of the path).

I think your insight around g_file_get_uri is a great lead. I was going to compile debug versions of librsvg and libvips, but didn’t have the tool chain set up on this new laptop, so I tried in docker... and everything suddenly worked as expected. We run Linux in production anyhow so I just pushed my changes, reported the issue here and went to bed :)

If I get a chance today, I’ll see if I can get a debug build for Mac running so I can print out the fully normalized paths being compared.

@lovell
Copy link
Owner

lovell commented Dec 28, 2018

@mike-marcacci Were you able to make any progress with this?

@mike-marcacci
Copy link
Author

mike-marcacci commented Dec 29, 2018

Hi @lovell, sadly I ran out of time (and will probably be fully preoccupied for the next several weeks). With this only broken on Mac, it’s taken a backseat to some other projects.

I do still hope to get around to diving back into this, though, since our development is done primarily on Mac.

@lovell
Copy link
Owner

lovell commented Mar 9, 2019

Please feel free to re-open this issue with more details if/when they become available.

@lovell lovell closed this as completed Mar 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants