Open iham opened 3 years ago
I wouldn't recommend this. This opens up a security hole that we patched in the May 2021 hotfix. See the XSS in file upload vulnerability page for a brief description.
Having said that, the approach is possible, but you should clean the svg to at least not contain script tags, on:click attributes, processing instructions, stuff like that. But I would only do that on a site that is only available in an internal network, and only has users that you trust, and you trust that your users won't get hacked. In other words: let's not add this in the core.
For small svg images from a filesystem theme, this could be fine: having the images inline means less requests are needed, although I guess this is less of a problem these days when you have http/2 configured in your webserver.
@mauritsvanrees thanks for pointing out that risk.
i guess this will be a collective thing then. still a transform taking care of script tags and such.
being able to style svg via css is my main focus here
But if you want to style it with CSS, i gues it will not be random images from users right? So if you have SVGs for special usecases, i gues a dedicated CT might be a better solution. This CT would be restricted to trusted users.
PLIP (Plone Improvement Proposal)
Responsible Persons
Proposer: @iham
Seconder: @agitator
Abstract
Render uploaded (Plone Content Type) images inline if they are svg‘s.
Motivation
Assumptions
Should/Could be in core as it deals with how svgs images are rendered using a transform. This is not theme specific. (I wrote the issue in plonetheme.barceloneta in the first place, which was wrong.)
Maybe adding a control panel (image handling?) checkbox to de/activate that transform can be an option, to keep the choice at user-level.
Proposal & Implementation
my approach was to write an adapter (python2 code!):
configure.zcml
and the transform itself: transform.py
Deliverables
Code this as a core-thing.
Risks
Participants
I tested the approach above on a project and it worked fine so far. If somebody shouts a go, i implement it, wherever you want it to be placed.