From 7cf6a47c7774797aabf63344375b030367aa6ac9 Mon Sep 17 00:00:00 2001 From: Anirudh Oppiliappan Date: Thu, 10 Jul 2025 17:26:22 +0300 Subject: [PATCH] appview,hook,knotserver: set charset=utf-8 for all text/plain responses Signed-off-by: Anirudh Oppiliappan --- appview/pulls/pulls.go | 2 +- appview/repo/repo.go | 2 +- hook/hook.go | 2 +- knotserver/handler.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/appview/pulls/pulls.go b/appview/pulls/pulls.go index 9de0aa15..a6263128 100644 --- a/appview/pulls/pulls.go +++ b/appview/pulls/pulls.go @@ -447,7 +447,7 @@ func (s *Pulls) RepoPullPatchRaw(w http.ResponseWriter, r *http.Request) { } } - w.Header().Set("Content-Type", "text/plain") + w.Header().Set("Content-Type", "text/plain; charset=utf-8") w.Write([]byte(pull.Submissions[roundIdInt].Patch)) } diff --git a/appview/repo/repo.go b/appview/repo/repo.go index 7ac528dc..f1df8643 100644 --- a/appview/repo/repo.go +++ b/appview/repo/repo.go @@ -590,7 +590,7 @@ func (rp *Repo) RepoBlobRaw(w http.ResponseWriter, r *http.Request) { return } - w.Header().Set("Content-Type", "text/plain") + w.Header().Set("Content-Type", "text/plain; charset=utf-8") w.Write([]byte(result.Contents)) return } diff --git a/hook/hook.go b/hook/hook.go index 194b49a1..f43b594a 100644 --- a/hook/hook.go +++ b/hook/hook.go @@ -63,7 +63,7 @@ func postRecieve(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("failed to create request: %w", err) } - req.Header.Set("Content-Type", "text/plain") + req.Header.Set("Content-Type", "text/plain; charset=utf-8") req.Header.Set("X-Git-Dir", gitDir) req.Header.Set("X-Git-User-Did", userDid) req.Header.Set("X-Git-User-Handle", userHandle) diff --git a/knotserver/handler.go b/knotserver/handler.go index b536c5d1..a7dc849f 100644 --- a/knotserver/handler.go +++ b/knotserver/handler.go @@ -187,6 +187,6 @@ func (h *Handle) Version(w http.ResponseWriter, r *http.Request) { } } - w.Header().Set("Content-Type", "text/plain") + w.Header().Set("Content-Type", "text/plain; charset=utf-8") fmt.Fprintf(w, "knotserver/%s", version) } -- 2.51.2