Skip to content

Commit

Permalink
Add checks for mention offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Mar 10, 2024
1 parent c4157b6 commit ad96a68
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions msgconv/mentions.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,14 @@ func (mc *MessageConverter) metaToMatrixText(ctx context.Context, text string, r
if mention.Offset < prevEnd {
zerolog.Ctx(ctx).Warn().Msg("Ignoring overlapping mentions in message")
continue
} else if mention.Offset >= len(utf16Text) {
zerolog.Ctx(ctx).Warn().Msg("Ignoring mention outside of message")
continue
}
end := mention.Offset + mention.Length
if end > len(utf16Text) {
end = len(utf16Text)
}
var mentionLink string
switch mention.Type {
case socket.MentionTypePerson:
Expand Down

0 comments on commit ad96a68

Please sign in to comment.