summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2022-08-21 07:50:15 +0100
committerGitHub <noreply@github.com>2022-08-21 02:50:15 -0400
commit11bae504846293806fec27f3271e0d3aba8f0f93 (patch)
treeb2e0356c8c442c336f0dfca497cce9bb22a57395 /routers
parent0ee96da052edd3fe25b66d2c9fd5fd3d01171091 (diff)
downloadgitea-11bae504846293806fec27f3271e0d3aba8f0f93.tar.gz
gitea-11bae504846293806fec27f3271e0d3aba8f0f93.zip
Pad GPG Key ID with preceding zeroes (#20878)
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/user/gpg_key.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/routers/api/v1/user/gpg_key.go b/routers/api/v1/user/gpg_key.go
index b211a24a0e..b87cf0041e 100644
--- a/routers/api/v1/user/gpg_key.go
+++ b/routers/api/v1/user/gpg_key.go
@@ -7,6 +7,7 @@ package user
import (
"fmt"
"net/http"
+ "strings"
asymkey_model "code.gitea.io/gitea/models/asymkey"
"code.gitea.io/gitea/models/db"
@@ -177,6 +178,12 @@ func VerifyUserGPGKey(ctx *context.APIContext) {
token := asymkey_model.VerificationToken(ctx.Doer, 1)
lastToken := asymkey_model.VerificationToken(ctx.Doer, 0)
+ form.KeyID = strings.TrimLeft(form.KeyID, "0")
+ if form.KeyID == "" {
+ ctx.NotFound()
+ return
+ }
+
_, err := asymkey_model.VerifyGPGKey(ctx.Doer.ID, form.KeyID, token, form.Signature)
if err != nil && asymkey_model.IsErrGPGInvalidTokenSignature(err) {
_, err = asymkey_model.VerifyGPGKey(ctx.Doer.ID, form.KeyID, lastToken, form.Signature)