Skip to content

Commit

Permalink
🍱 fix content-type header for ban and captcha page
Browse files Browse the repository at this point in the history
  • Loading branch information
max.lerebourg committed May 16, 2024
1 parent 8975216 commit 8fbf268
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 6 additions & 4 deletions bouncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,13 @@ type Login struct {
}

func handleBanServeHTTP(bouncer *Bouncer, rw http.ResponseWriter) {
rw.WriteHeader(http.StatusForbidden)
if bouncer.banTemplateString != "" {
rw.Header().Set("Content-Type", "text/html; charset=utf-8")
fmt.Fprint(rw, bouncer.banTemplateString)
if bouncer.banTemplateString == "" {
rw.WriteHeader(http.StatusForbidden)
return
}
rw.Header().Set("Content-Type", "text/html; charset=utf-8")
rw.WriteHeader(http.StatusForbidden)
fmt.Fprint(rw, bouncer.banTemplateString)
}

func handleRemediationServeHTTP(bouncer *Bouncer, remoteIP, remediation string, rw http.ResponseWriter, req *http.Request) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/captcha/captcha.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ func (c *Client) ServeHTTP(rw http.ResponseWriter, r *http.Request, remoteIP str
http.Redirect(rw, r, r.URL.String(), http.StatusFound)
return
}
rw.Header().Set("Content-Type", "text/html; charset=utf-8")
rw.WriteHeader(http.StatusOK)
err = c.captchaTemplate.Execute(rw, map[string]string{
"SiteKey": c.siteKey,
"FrontendJS": captcha[c.provider].js,
Expand Down

0 comments on commit 8fbf268

Please sign in to comment.