Skip to content

Commit e5d24ea

Browse files
authored
do not read form values (#50)
1 parent ab769ca commit e5d24ea

1 file changed

Lines changed: 2 additions & 10 deletions

File tree

main.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -281,20 +281,12 @@ func (bc *CaptchaProtect) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
281281
clientIP, ipRange := bc.getClientIP(req)
282282
challengeOnPage := bc.ChallengeOnPage()
283283
if challengeOnPage && req.Method == http.MethodPost {
284-
response := req.FormValue(bc.captchaConfig.key + "-response")
285-
if response == "" {
286-
if !slices.Contains(bc.config.ProtectHttpMethods, req.Method) {
287-
bc.next.ServeHTTP(rw, req)
288-
return
289-
}
290-
} else {
284+
if req.URL.Query().Get("challenge") != "" {
291285
statusCode := bc.verifyChallengePage(rw, req, clientIP)
292286
log.Info("Captcha challenge", "clientIP", clientIP, "method", req.Method, "path", req.URL.Path, "status", statusCode, "useragent", req.UserAgent())
293287
return
294288
}
295-
}
296-
297-
if req.URL.Path == bc.config.ChallengeURL {
289+
} else if req.URL.Path == bc.config.ChallengeURL {
298290
switch req.Method {
299291
case http.MethodGet:
300292
destination := req.URL.Query().Get("destination")

0 commit comments

Comments
 (0)