trim whitespaces so sharecode does match

This commit is contained in:
2022-02-01 03:17:37 +01:00
parent c822ce9396
commit 4b3b8d8053

View File

@@ -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: