Closed jenstornell closed 6 years ago
There's probably an issue with the mime type detection here.
Checking for the same mime type seemed to be the most reasonable way of validation so far. We also have this for Kirby 2. What would be the option to replace files otherwise? Can they simple be replaced with anything else and they would just inherit the name and the meta content? If yes, this would have a lot of logical steps involved.
I used the arrow-left.svg
from the starterkit and it looks like this:
<svg viewBox="0 0 24 12"><path d="M1.94 6a28.38 28.38 0 0 0 8-4.47L8.71 5h12.23v2H8.71L10 10.47A28.4 28.4 0 0 0 1.94 6z"/></svg>
I'm not an SVG expert but it looks like something is missing there? If so, maybe it's working as expected.
I'm not sure if it should be replaced by anything. A SVG file, replaced by a SVG file should however work.
I would probably just see if the extension was the same on both files, but maybe it's not that hacker proof?
It's a pretty radically optimized SVG. I guess we need to adjust our mime type detector for such SVGs.
Started to narrow it down:
BlueprintFileSection.php
at line 57 fails:
new MimeType($rules['mime']))->has($image->mime())
Testing $image->mime()
directly with the svg file, returns image/svg+xml
. However, when uploading the SVG at that line we only get text/plain
. And as filename phprDly2R
with no extension at all.
✅
When trying to replace an image it says "arrow-left.svg The mime type of the new file does not match the old one". Both files are svg and I can upload my file, but not replace over another svg file.
Do they really need to be the same mime type to be replaced? If yes, why?