Skip to content

Commit 27ee01e

Browse files
Gustedzeripathwxiaoguang
authored
Disable content sniffing on PlainTextBytes (#18359)
- Disable the browser's function to "sniff" for the content-type on the provided plain text, this will prevent the possible usage of user-controlled data being sent, which could be malicious. Co-authored-by: zeripath <[email protected]> Co-authored-by: wxiaoguang <[email protected]>
1 parent 6ad7a53 commit 27ee01e

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

modules/context/context.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ func (ctx *Context) PlainTextBytes(status int, bs []byte) {
292292
}
293293
ctx.Resp.WriteHeader(status)
294294
ctx.Resp.Header().Set("Content-Type", "text/plain;charset=utf-8")
295+
ctx.Resp.Header().Set("X-Content-Type-Options", "nosniff")
295296
if _, err := ctx.Resp.Write(bs); err != nil {
296297
log.Error("Write bytes failed: %v", err)
297298
}

0 commit comments

Comments
 (0)