From 9c590c9bc6e80788f8ddd05c5ad0b0df997bc900 Mon Sep 17 00:00:00 2001 From: Seednode Date: Thu, 25 Jan 2024 09:30:28 -0600 Subject: [PATCH] Specify 'charset=UTF-8' for all text/plain content type headers --- cmd/index.go | 2 +- cmd/info.go | 6 +++--- cmd/root.go | 2 +- cmd/web.go | 4 +++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cmd/index.go b/cmd/index.go index 3367bf9..1a7211f 100644 --- a/cmd/index.go +++ b/cmd/index.go @@ -196,7 +196,7 @@ func serveIndexRebuild(args []string, index *fileIndex, formats types.Types, enc fileList(args, &filters{}, "", index, formats, encoder, errorChannel) - w.Header().Set("Content-Type", "text/plain") + w.Header().Set("Content-Type", "text/plain;charset=UTF-8") _, err := w.Write([]byte("Ok\n")) if err != nil { diff --git a/cmd/info.go b/cmd/info.go index fd279f4..a1cdfbb 100644 --- a/cmd/info.go +++ b/cmd/info.go @@ -26,7 +26,7 @@ func serveIndex(args []string, index *fileIndex, errorChannel chan<- error) http return strings.ToLower(indexDump[p]) < strings.ToLower(indexDump[q]) }) - w.Header().Set("Content-Type", "application/json") + w.Header().Set("Content-Type", "application/json;charset=UTF-8") response, err := json.MarshalIndent(indexDump, "", " ") if err != nil { @@ -59,7 +59,7 @@ func serveExtensions(formats types.Types, available bool, errorChannel chan<- er return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { startTime := time.Now() - w.Header().Set("Content-Type", "text/plain") + w.Header().Set("Content-Type", "text/plain;charset=UTF-8") var extensions string @@ -89,7 +89,7 @@ func serveMediaTypes(formats types.Types, available bool, errorChannel chan<- er return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { startTime := time.Now() - w.Header().Set("Content-Type", "text/plain") + w.Header().Set("Content-Type", "text/plain;charset=UTF-8") var mediaTypes string diff --git a/cmd/root.go b/cmd/root.go index b22725b..4da6971 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -17,7 +17,7 @@ import ( const ( AllowedCharacters string = `^[A-z0-9.\-_]+$` - ReleaseVersion string = "6.3.0" + ReleaseVersion string = "6.3.1" ) var ( diff --git a/cmd/web.go b/cmd/web.go index f105e3f..0bdbca3 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -55,7 +55,7 @@ func newPage(title, body string) string { func noFiles(w http.ResponseWriter, r *http.Request) { startTime := time.Now() - w.Header().Set("Content-Type", "text/plain") + w.Header().Set("Content-Type", "text/plain;charset=UTF-8") w.Write([]byte("No files found in the specified path(s).\n")) @@ -424,6 +424,8 @@ func serveVersion(errorChannel chan<- error) httprouter.Handle { data := []byte(fmt.Sprintf("roulette v%s\n", ReleaseVersion)) + w.Header().Set("Content-Type", "text/plain;charset=UTF-8") + w.Header().Set("Content-Length", strconv.Itoa(len(data))) written, err := w.Write(data)