Skip to content

Commit 60f4ed1

Browse files
committed
Update, use ReplaceAll for when replacing the erro code and err description
1 parent 4834645 commit 60f4ed1

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

apps/internal/local/server.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,8 @@ func (s *Server) handler(w http.ResponseWriter, r *http.Request) {
169169

170170
errDesc := q.Get("error_description")
171171

172-
if bytes.Contains(s.errorPage, code) {
173-
s.errorPage = bytes.Replace(s.errorPage, code, []byte(html.EscapeString(headerErr)), 1) // provides XSS protection
174-
}
175-
176-
if bytes.Contains(s.errorPage, err) {
177-
s.errorPage = bytes.Replace(s.errorPage, err, []byte(html.EscapeString(errDesc)), 1) // provides XSS protection
178-
}
172+
s.errorPage = bytes.ReplaceAll(s.errorPage, code, []byte(html.EscapeString(headerErr))) // provides XSS protection
173+
s.errorPage = bytes.ReplaceAll(s.errorPage, err, []byte(html.EscapeString(errDesc))) // provides XSS protection
179174

180175
_, _ = w.Write(s.errorPage)
181176

0 commit comments

Comments
 (0)