SVG could be dangerous, especially coming from an external site. However, even not enabled by default, there should be a way for devs that know what they are doing to add SVG support. Here's a proposal:
- Move the hardcoded list of extensions into a config, so that a site admin is able to add
.svg to the list
- Before saving the file content, dispatch a hook that allows 3rd-party to perform sanitization on the downloaded file. Allow the subscribers to cancel the file saving if they aren't able to sanitize the file.
Alternatively (more secure), depend on enshrined/svg-sanitize and do the sanitization by default.
I prefer the 2nd options as is more secure,
Comments
Comment #3
claudiu.cristeaThis is ready for review and has tests
Comment #4
larowlanLooks good to me. I've not been an active maintainer here since Drupal 6 so will defer to swentel for the next steps.
Comment #5
tim_djThis doesn't work out of the box. You need to add "image/svg+xml" to imagecache_external_allowed_mimetypes in imagecache_external.settings
I think this should be either added as default or there should be an UI to enable this.
Comment #6
claudiu.cristea@tim_dj, indeed
imagecache_external_allowed_mimetypessetting is not exposed in the admin form. But that is not an effect of this issue. I think you can open a follow-up to make this setting editableComment #7
tim_dj@claudiu.cristea then at the very least this should be documented because now it just doesn't work out of the box and I had to debug to find the cause
Comment #8
swentel commentedCool! I agree however, that the mimetype should be added to the settings as well.
I see 2 options:
1. an update hook: there's an existing one, 'imagecache_external_update_8103' which does this for image/webp.
2. Add the mimetype as soon as you configure the svg settings in the UI.
I kind of prefer number 2: add when you configure tags, remove when svg tags are removed.
Comment #11
herved commentedIt looks like something went wrong with the last merge in 3390948-svg (in , imagecache_external.module
imagecache_sanitize_svggot removed).I created a new 3390948-svg-2 branch, rebased on 3.0.x.
Comment #13
swentel commentedGoing to review this over the weekend
Comment #15
swentel commentedAdded a test that image/svg+xml is added or removed from the allowed mimetypes depending on the svg settings. Will merge in soon.
Comment #16
swentel commentedMerged. Will release soon after merging two other issues.
Comment #18
swentel commented