消息解析=号问题

This commit is contained in:
TsMask
2023-08-23 17:21:15 +08:00
parent 8148a77de6
commit d40bdc39f2

View File

@@ -74,6 +74,9 @@ func Decode(data []byte, body *model.Body) error {
if idx == -1 {
idx = strings.LastIndex(name, "\x00")
}
if idx == -1 {
idx = strings.LastIndex(name, "\xe2")
}
if idx > 0 {
name = name[idx+1:]
@@ -87,11 +90,13 @@ func Decode(data []byte, body *model.Body) error {
// 解析data KEY
body.Data = make(map[string]string)
for i := 1; i < len(multi); i++ {
m := strings.Split(multi[i], "=")
if len(m) != 2 {
return errors.New("invalid msg body")
str := multi[i]
idx := strings.Index(str, "=")
if idx > 0 {
key := str[:idx]
value := str[idx+1:]
body.Data[key] = value
}
body.Data[m[0]] = m[1]
}
return nil