threading: fix stack overflow from faulty headers
Fix stack overflow from faulty headers that cause a circularity in the threading algorithm. Remove duplicated message-ids in the references headers. Check that the message-id itself is not part of the references. Fixes: https://todo.sr.ht/~rjarry/aerc/32 Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Robin Jarry <robin@jarry.cc> Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
parent
4c699d35f8
commit
93c160ab66
|
@ -200,7 +200,19 @@ func (t *threadable) MessageThreadReferences() []string {
|
|||
}
|
||||
refs = []string{inreplyto}
|
||||
}
|
||||
return refs
|
||||
return cleanRefs(t.MessageThreadID(), refs)
|
||||
}
|
||||
|
||||
func cleanRefs(m string, refs []string) []string {
|
||||
considered := make(map[string]interface{})
|
||||
cleanRefs := make([]string, 0, len(refs))
|
||||
for _, r := range refs {
|
||||
if _, seen := considered[r]; r != m && !seen {
|
||||
considered[r] = nil
|
||||
cleanRefs = append(cleanRefs, r)
|
||||
}
|
||||
}
|
||||
return cleanRefs
|
||||
}
|
||||
|
||||
func (t *threadable) Subject() string {
|
||||
|
|
Loading…
Reference in New Issue