Merge branch 'main' into feature/bots

This commit is contained in:
Jason Song
2022-11-29 11:09:20 +08:00
committed by GitHub
10 changed files with 36 additions and 31 deletions

View File

@@ -8,9 +8,9 @@ import (
"crypto/sha1"
"crypto/sha256"
"crypto/sha512"
"encoding/hex"
"encoding/xml"
"errors"
"fmt"
"io"
"net/http"
"path/filepath"
@@ -128,7 +128,7 @@ func serveMavenMetadata(ctx *context.Context, params parameters) {
tmp := sha512.Sum512(xmlMetadataWithHeader)
hash = tmp[:]
}
ctx.PlainText(http.StatusOK, fmt.Sprintf("%x", hash))
ctx.PlainText(http.StatusOK, hex.EncodeToString(hash))
return
}

View File

@@ -4,7 +4,7 @@
package pypi
import (
"fmt"
"encoding/hex"
"io"
"net/http"
"regexp"
@@ -118,7 +118,7 @@ func UploadPackageFile(ctx *context.Context) {
_, _, hashSHA256, _ := buf.Sums()
if !strings.EqualFold(ctx.Req.FormValue("sha256_digest"), fmt.Sprintf("%x", hashSHA256)) {
if !strings.EqualFold(ctx.Req.FormValue("sha256_digest"), hex.EncodeToString(hashSHA256)) {
apiError(ctx, http.StatusBadRequest, "hash mismatch")
return
}