rookie0 / nextcloud-sharing-path

🌩 Nextcloud app to enhance files sharing to be accessed by stored path, can be used as CDN origin.
GNU Affero General Public License v3.0
47 stars 11 forks source link

SVG file MIME is wrong on Nextcloud 21 #38

Closed amirhmoradi closed 2 years ago

amirhmoradi commented 3 years ago

Hi, thanks for your great work. I am using Nextcloud 21 and Sharingpath 0.4.1, installed manually. I am serving my shared images through an image processor (imagekit.io) with a layer of caching on cloudflare.

My SVG files do not render as images, but render as text content.

In the mimetypemapping.dist.json file on nextcloud 21, the svg extension has the following values: "image/svg+xml" AND "text/plain"

When using the getSecureMimeType function in nextcloud-sharing-path/lib/Controller/PathController.php, only the second value is sent, so the SVG file renders as plain text.

To fix this, I created the following file in my nextcloud installation (doc https://docs.nextcloud.com/server/latest/admin_manual/configuration_mimetypes/index.html ) :

<nextcloud_root>/config/mimetypemapping.json

with content:

{ "svg": ["image/svg+xml"] }

So it will always return the correct mime type for svg files.

Maybe you could update the getSecureMimeType behaviour?

rookie0 commented 2 years ago

Do not know what behaviour you want?

And i think custom config like you set <nextcloud_root>/config/mimetypemapping.json is the right way.