First merge from develop to main (WIP) #7

Merged
sugar merged 199 commits from develop into main 2026-01-27 17:47:07 +00:00
2 changed files with 28 additions and 0 deletions
Showing only changes of commit 8dbdb58327 - Show all commits

View File

@@ -0,0 +1,20 @@
package cryptography
import (
"encoding/base64"
"strings"
)
func IsBase64Std(s string) bool {
if s == "" {
return false
}
s = strings.TrimSpace(s)
if len(s)%4 != 0 {
return false
}
_, err := base64.StdEncoding.Strict().DecodeString(s)
return err == nil
}

View File

@@ -2,6 +2,7 @@ package user
import (
"nixcn-cms/data"
"nixcn-cms/internal/cryptography"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
@@ -37,6 +38,13 @@ func Update(c *gin.Context) {
user.Nickname = ReqInfo.Nickname
user.Subtitle = ReqInfo.Subtitle
if ReqInfo.Bio != "" {
if !cryptography.IsBase64Std(ReqInfo.Bio) {
c.JSON(400, gin.H{"status": "invalid base64"})
}
}
user.Bio = ReqInfo.Bio
// Update user info
user.UpdateByUserID(userId)