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

When an invalid SVG file is uploaded, give the user a hint on how to fix. #37

Open
colourgarden opened this issue Sep 23, 2019 · 1 comment
Assignees

Comments

@colourgarden
Copy link
Contributor

Problem

  • Even after allowing SVG mime type uploads in Fixed SVG image uploads are not accepted by media library. #35, it's still a common problem that "clean" SVGs are not accepted by the Wordpress uploader
  • SVGs must have the doctype defined in the first line to be correctly identified as an SVG file by Wordpress - <?xml version="1.0" encoding="utf-8"?>
  • SVG cleaners like ImageOptim and SVGO - which we should encourage the use of - will often remove the <?xml ?> declaration
  • There's no safe technical solution to this issue. Automatically adding the declaration via PHP could lead to unsafe SVGs being allowed by default

Solution

  • When SVG is detected as the file extension, adjust the Sorry, this file type is not permitted for security reasons. message to include a hint about adding the XML declaration as the first line

Notes

@colourgarden
Copy link
Contributor Author

colourgarden commented Sep 23, 2019

Submitted a PR to ImageOptim which may help with this issue (at least for Mac users) - ImageOptim/ImageOptim#300

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

No branches or pull requests

3 participants