Skip to content

Commit

Permalink
fix: panic when no cookie is sent
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Jan 8, 2022
1 parent 4d5f0ef commit 26e50f5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func (h *CSRFHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Finally, we check the token itself.
sentToken := extractToken(r)

if !verifyToken(realTokens[0], sentToken) {
if len(realTokens) != 1 || !verifyToken(realTokens[0], sentToken) {
ctxSetReason(r, ErrBadToken)
h.handleFailure(w, r)
return
Expand Down

0 comments on commit 26e50f5

Please sign in to comment.