Specify 'charset=UTF-8' for all text/plain content type headers

This commit is contained in:
Seednode 2024-01-25 09:30:28 -06:00
parent 172fc38f18
commit 9c590c9bc6
4 changed files with 8 additions and 6 deletions

View File

@ -196,7 +196,7 @@ func serveIndexRebuild(args []string, index *fileIndex, formats types.Types, enc
fileList(args, &filters{}, "", index, formats, encoder, errorChannel) 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")) _, err := w.Write([]byte("Ok\n"))
if err != nil { if err != nil {

View File

@ -26,7 +26,7 @@ func serveIndex(args []string, index *fileIndex, errorChannel chan<- error) http
return strings.ToLower(indexDump[p]) < strings.ToLower(indexDump[q]) 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, "", " ") response, err := json.MarshalIndent(indexDump, "", " ")
if err != nil { 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) { return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
startTime := time.Now() startTime := time.Now()
w.Header().Set("Content-Type", "text/plain") w.Header().Set("Content-Type", "text/plain;charset=UTF-8")
var extensions string 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) { return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
startTime := time.Now() startTime := time.Now()
w.Header().Set("Content-Type", "text/plain") w.Header().Set("Content-Type", "text/plain;charset=UTF-8")
var mediaTypes string var mediaTypes string

View File

@ -17,7 +17,7 @@ import (
const ( const (
AllowedCharacters string = `^[A-z0-9.\-_]+$` AllowedCharacters string = `^[A-z0-9.\-_]+$`
ReleaseVersion string = "6.3.0" ReleaseVersion string = "6.3.1"
) )
var ( var (

View File

@ -55,7 +55,7 @@ func newPage(title, body string) string {
func noFiles(w http.ResponseWriter, r *http.Request) { func noFiles(w http.ResponseWriter, r *http.Request) {
startTime := time.Now() 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")) 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)) 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))) w.Header().Set("Content-Length", strconv.Itoa(len(data)))
written, err := w.Write(data) written, err := w.Write(data)