Skip to content

Commit

Permalink
escape errors rendered by InternalError
Browse files Browse the repository at this point in the history
  • Loading branch information
mmarchetti committed Aug 22, 2024
1 parent 61a4ff0 commit e339ab3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/services/api/api_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package api
import (
"errors"
"fmt"
"html"
"net/http"

"github.com/posit-dev/publisher/internal/logging"
Expand All @@ -13,7 +14,8 @@ import (

func InternalError(w http.ResponseWriter, req *http.Request, log logging.Logger, err error) {
status := http.StatusInternalServerError
text := err.Error()
text := html.EscapeString(err.Error())
w.Header().Add("Content-Type", "text/plain")
w.WriteHeader(status)
w.Write([]byte(text))
log.Error(text, "method", req.Method, "url", req.URL.String(), "error", err)
Expand Down

0 comments on commit e339ab3

Please sign in to comment.