Skip to content

Commit b42779a

Browse files
authored
Close XSS issue in /base64 endpoint (fixes #67) (#68)
1 parent e2bb3ec commit b42779a

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

httpbin/handlers.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ func (h *HTTPBin) Base64(w http.ResponseWriter, r *http.Request) {
982982
http.Error(w, fmt.Sprintf("%s failed: %s", b.operation, base64Error), http.StatusBadRequest)
983983
return
984984
}
985-
writeResponse(w, http.StatusOK, "text/html", result)
985+
writeResponse(w, http.StatusOK, "text/plain", result)
986986
}
987987

988988
// JSON - returns a sample json

httpbin/handlers_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -2425,6 +2425,7 @@ func TestBase64(t *testing.T) {
24252425
w := httptest.NewRecorder()
24262426
handler.ServeHTTP(w, r)
24272427
assertStatusCode(t, w, http.StatusOK)
2428+
assertContentType(t, w, "text/plain")
24282429
assertBodyEquals(t, w, test.want)
24292430
})
24302431
}

0 commit comments

Comments
 (0)