Skip to content

fix: message #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions message/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,12 @@ func ParsePrivateMessage(msg *message.PushMsgBody) *PrivateMessage {
UID: msg.ResponseHead.FromUid.Unwrap(),
IsFriend: true,
},
Time: msg.ContentHead.TimeStamp.Unwrap(),
Elements: ParseMessageElements(msg.Body.RichText.Elems),
Time: msg.ContentHead.TimeStamp.Unwrap(),
}
if msg.Body != nil {
prvMsg.Elements = ParseMessageElements(msg.Body.RichText.Elems)
prvMsg.Elements = append(prvMsg.Elements, ParseMessageBody(msg.Body, false)...)
}

return prvMsg
}

Expand All @@ -125,11 +124,12 @@ func ParseGroupMessage(msg *message.PushMsgBody) *GroupMessage {
CardName: msg.ResponseHead.Grp.MemberName,
IsFriend: false,
},
Time: msg.ContentHead.TimeStamp.Unwrap(),
Elements: ParseMessageElements(msg.Body.RichText.Elems),
Time: msg.ContentHead.TimeStamp.Unwrap(),

OriginalObject: msg,
}
if msg.Body != nil {
grpMsg.Elements = ParseMessageElements(msg.Body.RichText.Elems)
grpMsg.Elements = append(grpMsg.Elements, ParseMessageBody(msg.Body, true)...)
}
return grpMsg
Expand Down Expand Up @@ -288,7 +288,7 @@ func ParseMessageElements(msg []*message.Elem) []IMessageElement {
case 48:
extra := &oidb2.MsgInfo{}
err := proto.Unmarshal(elem.CommonElem.PbElem, extra)
if err != nil {
if err != nil || len(extra.MsgInfoBody) == 0 { // 不合理的合并转发会导致越界
continue
}
index := extra.MsgInfoBody[0].Index
Expand All @@ -314,6 +314,7 @@ func ParseMessageElements(msg []*message.Elem) []IMessageElement {
Sha1: utils.MustParseHexStr(index.Info.FileSha1),
Duration: index.Info.Time,
Node: index,
MsgInfo: extra,
})
case 11, 21: // video
var thumb = new(VideoThumb)
Expand All @@ -326,13 +327,14 @@ func ParseMessageElements(msg []*message.Elem) []IMessageElement {
thumb.Sha1 = utils.MustParseHexStr(info.Info.FileSha1)
}
res = append(res, &ShortVideoElement{
Name: index.Info.FileName,
UUID: index.FileUuid,
Md5: utils.MustParseHexStr(index.Info.FileHash),
Sha1: utils.MustParseHexStr(index.Info.FileSha1),
Size: index.Info.FileSize,
Thumb: thumb,
Node: index,
Name: index.Info.FileName,
UUID: index.FileUuid,
Md5: utils.MustParseHexStr(index.Info.FileHash),
Sha1: utils.MustParseHexStr(index.Info.FileSha1),
Size: index.Info.FileSize,
Thumb: thumb,
Node: index,
MsgInfo: extra,
})
}
case 3: // 闪照
Expand Down