tenseleyflow/shithub / 6b8db0c

Browse files

Mark PR raw diff as plain text

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
6b8db0ce1a08c237ac82aeef7f66a43fa247040b
Parents
09fc23c
Tree
474064f

1 changed file

StatusFile+-
M internal/web/handlers/repo/pulls.go 2 1
internal/web/handlers/repo/pulls.gomodified
@@ -735,8 +735,9 @@ func (h *Handlers) pullRawDiff(w http.ResponseWriter, r *http.Request) {
735735
 		ext = ".patch"
736736
 	}
737737
 	w.Header().Set("Content-Type", "text/plain; charset=utf-8")
738
+	w.Header().Set("X-Content-Type-Options", "nosniff")
738739
 	w.Header().Set("Content-Disposition", "inline; filename=\""+row.Name+"-"+strconv.FormatInt(pr.INumber, 10)+ext+"\"")
739
-	_, _ = w.Write(patch)
740
+	_, _ = w.Write(patch) // #nosec G705 -- git diff bytes are served as text/plain with nosniff, not HTML.
740741
 }
741742
 
742743
 // pullChecks renders the Checks tab. Loads suites + runs grouped by