Skip to content
This repository has been archived by the owner on Jul 26, 2023. It is now read-only.

Adding SVG support? #21

Open
BoomerScratch opened this issue Aug 2, 2020 · 10 comments
Open

Adding SVG support? #21

BoomerScratch opened this issue Aug 2, 2020 · 10 comments
Labels
enhancement New feature or request needs discussion

Comments

@BoomerScratch
Copy link
Contributor

Currently, if you upload an SVG image, the image will not appear and a 500 error occurs.
We should convert the SVG to PNG. This is easy: you can create a canvas element, render the SVG on it, and finally grab a picture of the canvas using canvas.toDataURL.
The harder part is that it doesn't work if the canvas is offscreen. To fix that, we can use @canvg. Create a file called canvg.js with these contents, and also add it to the content scripts in manifest.json.
We first need to merge #20 before I can start working on it.

@BoomerScratch
Copy link
Contributor Author

Okay, this is kinda hard to do 😅

@easrng
Copy link
Contributor

easrng commented Aug 14, 2020

or, y'know, OffscreenCanvas

@BoomerScratch
Copy link
Contributor Author

@easrng Yes, that is what I tried. I noticed some days ago that canvg isn't needed; it's built-in in most browsers.

@jeffalo jeffalo added enhancement New feature or request needs discussion labels Aug 21, 2020
@NoobTracker
Copy link

Currently, the thumbnails don't support SVG. But there's a way of still doing it: Using assets.scratch.mit.edu.

@BoomerScratch
Copy link
Contributor Author

@NoobTracker assets.scratch.mit.edu is not whitelisted.

@NoobTracker
Copy link

NoobTracker commented Aug 22, 2020

Ohhh it's possible. I found an exploit that makes that possible. Look at this, someone either copied my idea or discovered it too. And it is technically whitelisted.

@BoomerScratch
Copy link
Contributor Author

@NoobTracker Oh, that's interesting.

@NoobTracker
Copy link

Indeed. You need to use get_image/ or something like that (y'know, one of the whitelisted paths) and then you need to get one directory higher by using ../, but since .. is blacklisted in URLs, you need to use %2E%2E/.

@BoomerScratch
Copy link
Contributor Author

Ping @JeffaloBob, assets are possible.

@NoobTracker
Copy link

I already told Jeffalo, he tried it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request needs discussion
Projects
None yet
Development

No branches or pull requests

4 participants