Open JornWildt opened 6 years ago
Seems like it could be related to this https://github.com/solid/node-solid-server/issues/413
According to the linked issue you're uusing mime-db
via mime
package. I suggest to not rely on the file extension, but on the first bytes (a.k.a. magic bytes) to determine the Content-Type.
Otherwise people could upload malware with an unsuspecting file extension...
This, indeed, sounds like a bad idea. There is a TAG finding on it too: https://www.w3.org/2001/tag/doc/mime-respect.html#dav-scenario We need to figure out why this was done.
@RubenVerborgh confirms, this will be fixed with #662
yea when application/octet-stream content type is set there is no effect; seems to be treated as a turtle file. the dependency https://github.com/jshttp/mime-types should know what it is. when read back from the pod the file doesn't match the original
This, indeed, sounds like a bad idea. There is a TAG finding on it too: https://www.w3.org/2001/tag/doc/mime-respect.html#dav-scenario We need to figure out why this was done.
From what I read there it deals with a mismatch about Content-Type and file extension. What I meant is more what file does.
If you want to learn more about Magic Bytes, read Magic Bytes – Identifying Common File Formats at a Glance.
I have tried to upload various images to my POD and at some point I named it "x-jpg" instead of "x.jpg". It turns out that the solid server uses the filename extention to detect content type instead of relying on the actual content type.
Here is an example PUT operation showing the name "...270-jpg" and the content-type "image/jpeg":
Later on I do a GET on https://elfisk.solid.community/public/solidrc/images/ which returns the document below. You can see that ".jpg" files have type "jpeg:Resource" whereas the "-jpg" files does not.
Later on the data browser goes beserk when you try to delete the "*-jpg" image as it is served as a turtle document: