Skip to content

Fix name extraction variables in message snippets

Variables like "%TOLNAME" in message snippets fail if the message's display name contains a comma, like

"LastName, FirstName" <mail@xx.yy>

The reason for this are two bugs addressed in this PR:

  1. the function TemplateParser::Util::getLastNameFromEmail returns an empty string for "LastName" because of an off-by-1 error in the parsing code.
  2. The functions ConvertSnippetVariablesJob::getFirstNameFromEmail and ConvertSnippetVariablesJob::getLastNameFromEmail split the given list of addresses at comma characters using QString::split. However, this fails if the display name of an address contains a comma itself (as in the example above). The fix is to use KEmailAddress::splitAddressList, which handles quoted display names correctly.
Edited by Frank Fischer

Merge request reports