From 4b3b8d80531258118f13c41817d3d22816284c3e Mon Sep 17 00:00:00 2001 From: Giovanni Harting <539@idlegandalf.com> Date: Tue, 1 Feb 2022 03:17:37 +0100 Subject: [PATCH] trim whitespaces so sharecode does match --- main.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 6760584..a42c999 100644 --- a/main.go +++ b/main.go @@ -31,6 +31,7 @@ import ( "os" "os/signal" "strconv" + "strings" "syscall" "time" ) @@ -495,8 +496,8 @@ func postPlayerTrack(w http.ResponseWriter, r *http.Request) { } id := mux.Vars(r)["id"] - authCode := r.Form.Get("authcode") - shareCode := r.Form.Get("sharecode") + authCode := strings.TrimSpace(r.Form.Get("authcode")) + shareCode := strings.TrimSpace(r.Form.Get("sharecode")) if id == "" || authCode == "" || !utils.AuthCodeRegEx.MatchString(authCode) { log.Infof("[PPT] invalid arguments: %+v, %+v, %+v", id, authCode, shareCode) @@ -528,7 +529,7 @@ func postPlayerTrack(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusUnauthorized) return case utils.SharecodeNoMatchError: - log.Infof("[PPT] shareCode provided for player %s is invalid: %v", id, e) + log.Infof("[PPT] shareCode provided for player %s (%s) is invalid: %v", id, shareCode, e) w.WriteHeader(http.StatusPreconditionFailed) return default: