Bug 392018

Summary: Contact group resolution can go crazy due to recursively resolving on a part of the group name
Product: [Applications] kontact Reporter: Anton Kreuzkamp <akreuzkamp>
Component: mailAssignee: kdepim bugs <kdepim-bugs>
Status: REPORTED ---    
Severity: normal CC: david.narvaez, marc+bugs
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:

Description Anton Kreuzkamp 2018-03-18 20:22:15 UTC
I had a contact group named "Family Mustermann". Guess what happens if you try to write a mail to "Max Mustermann <max.mustermann@example.com>".

Kontact wants to resolve the contact group "Family Mustermann" based on the match "Mustermann". That causes "Erika Mustermann <erika.mustermann@example.com>" and "Max Mustermann <max.mustermann@example.com>" to be loaded into the recipient list. Both of them cause Kontact to resolve the contact group "Family Mustermann" based on the match "Mustermann"... That doesn't only go until the maximal number of recipients is reached, but continues after that, causing error messages about the full recipient list to be created infinitely.
If you don't kill Kontact immediately the mail will be auto-saved and reappear on a restart of Kontact, driving Kontact completely unusuable until you delete the draft manually in the file system.

The same thing doesn't happen in KMail, as KMail apparently doesn't resolve contact groups. It also doesn't happen if you insert e.g. "Max <Mustermann@example.com>" so resolution does only happen based on the name, not on the e-mail address.

Reproducible: Always

Steps to Reproduce:
1. Create a contact group (e.g. "Family Mustermann"), whose name contains a word (e.g. "Mustermann") that is also part of the name of one of the group members (e.g. "Max Mustermann").
2. Compose a new mail
3. Insert the name of one of those recipients that have a partial name match with the contact group name (e.g. "Max Mustermann <max.mustermann@example.com")
4. choose the proposed auto completion item or write the full address manually and click outside the line edit.

Actual Results:
The contact group is resolved, resulting in the original recipient to appear a second time and kicks off an infinite recursion of resolving the contact group.

Expected behaviour:
Only the inserted recipient (e.g. "Max Mustermann <max.mustermann@example.com>") is added to the recipient list, without the contact group being resolved.

Proposed fix:
You could either not resolve contact groups based on only part of the name and/or you could during contact group resolution filter out lines that contain a full email address.
Comment 1 David E. Narvaez 2020-06-05 14:42:11 UTC
This happens in KMail 19.12.3 if you have "Automatically expand groups" selected (when you right-click on the recipients area).