Skip to content

Commit

Permalink
Silence CodeQL warning
Browse files Browse the repository at this point in the history
  • Loading branch information
IngmarStein committed May 27, 2024
1 parent 1b293d9 commit 35e02d6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions example/http-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/http"
"net/http/httputil"
"os"
"strings"
)

func getPort() string {
Expand All @@ -16,6 +17,8 @@ func getPort() string {
return port
}

var httpHeaderValueSanitizer = strings.NewReplacer("\n", "-", "\r", "-")

func headers(w http.ResponseWriter, req *http.Request) {
dump, err := httputil.DumpRequest(req, true)
if err != nil {
Expand All @@ -25,8 +28,7 @@ func headers(w http.ResponseWriter, req *http.Request) {

for name, headers := range req.Header {
for _, h := range headers {

_, err := fmt.Fprintf(w, "%v: %v\n", name, h)
_, err := fmt.Fprintf(w, "%v: %v\n", name, httpHeaderValueSanitizer.Replace(h))
if err != nil {
fmt.Printf("Error writing header %s: %v\n", name, err)
return
Expand Down

0 comments on commit 35e02d6

Please sign in to comment.