gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
75.38k stars 7.49k forks source link

hugo server adds unnecessary charset parameter to Content-Type for images #10734

Closed SpecLad closed 8 months ago

SpecLad commented 1 year ago

What version of Hugo are you using (hugo version)?

> hugo version
hugo v0.110.0-e32a493b7826d02763c3b79623952e625402b168+extended windows/amd64 BuildDate=2023-01-17T12:16:09Z VendorInfo=gohugoio

Does this issue reproduce with the latest release?

Yes.


Add an image to a site's static directory, run hugo server, and look at the headers it gets served with:

> curl -I http://localhost:1313/images/cicero.jpg
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: 23595
Content-Type: image/jpeg; charset=utf-8
Last-Modified: Thu, 16 Feb 2023 19:49:44 GMT
Date: Sun, 19 Feb 2023 18:09:32 GMT

The Content-Type is set to image/jpeg; charset=utf-8, which is clearly wrong, as images don't have a charset parameter.

It's a minor issue, and I haven't noticed it actually breaking anything, but still, it's a bug.

bep commented 1 year ago

i suspect this is an upstream issue (we use the file server in the Go stdlib) -- and I suspect it's implemented this way for simplicity, and I'm not totally sure that it has any practical downside.

jmooring commented 1 year ago

It's been like this for years. Given that the server is not intended for production, I agree that there is no practical downside.

It worked as expected in v0.54.0, but stopped working with v0.55.0. Git bisect says 597e418cb02883418f2cebb41400e8e61413f651 is the first bad commit.

SpecLad commented 1 year ago

Seems like the behavior is implemented here:

https://github.com/gohugoio/hugo/blob/9af78d11003ed22b6281e47e1ac19568cf1cca81/hugolib/site.go#L939

github-actions[bot] commented 7 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.