Repository: gohugoio/hugo (language: go)

Issue:
hugo server adds unnecessary charset parameter to Content-Type for images
<!-- Please answer these questions before submitting your issue. Thanks! -->

### What version of Hugo are you using (`hugo version`)?

<pre>
> hugo version
hugo v0.110.0-e32a493b7826d02763c3b79623952e625402b168+extended windows/amd64 BuildDate=2023-01-17T12:16:09Z VendorInfo=gohugoio
</pre>

### 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:

```console
> 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.



Discussion / hints:
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.
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.
Seems like the behavior is implemented here:

https://github.com/gohugoio/hugo/blob/9af78d11003ed22b6281e47e1ac19568cf1cca81/hugolib/site.go#L939


Fix patch:
diff --git a/hugolib/site.go b/hugolib/site.go
index 312f6b97f1c..8ae09dd0f6e 100644
--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -397,7 +397,7 @@ func (w *whatChanged) Changes() []identity.Identity {
 func (s *Site) RegisterMediaTypes() {
 	for _, mt := range s.conf.MediaTypes.Config {
 		for _, suffix := range mt.Suffixes() {
-			_ = mime.AddExtensionType(mt.Delimiter+suffix, mt.Type+"; charset=utf-8")
+			_ = mime.AddExtensionType(mt.Delimiter+suffix, mt.Type)
 		}
 	}
 }


Test patch: