fix(canvas): 素材库 - 拒绝空字节数并提供历史数据修复工具
This commit is contained in:
1 parent
6a1e3db8be
commit
927604e644
7 files changed
+404
-1
No files matched your search
@@ -176,6 +176,11 @@ func requiredJSONNumberField(object map[string]json.RawMessage, key string) (flo
|
||||
if !ok {
|
||||
return 0, kernel.BadAuthRequest("素材缺少 " + key + " 字段")
|
||||
}
|
||||
// json.Unmarshal(null, &float64) succeeds without assigning a value.
|
||||
// Reject null explicitly so the persisted JSON obeys the client contract.
|
||||
if bytes.Equal(bytes.TrimSpace(raw), []byte("null")) {
|
||||
return 0, kernel.BadAuthRequest("素材字段 " + key + " 必须是数字")
|
||||
}
|
||||
var value float64
|
||||
if err := json.Unmarshal(raw, &value); err != nil {
|
||||
return 0, kernel.BadAuthRequest("素材字段 " + key + " 必须是数字")
|
||||
|
||||
Reference in new issue
Block a user