Skip to content

Commit

Permalink
Merge pull request #2152 from posit-dev/mm-internal-error
Browse files Browse the repository at this point in the history
Escape errors rendered by InternalError
  • Loading branch information
mmarchetti authored Aug 23, 2024
2 parents 43132de + e339ab3 commit f17f0e5
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 f17f0e5

Please sign in to comment.