<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>370385</bug_id>
          
          <creation_ts>2016-10-10 00:55:10 +0000</creation_ts>
          <short_desc>EMail Addresses with Underscores in Contacts Not Recognised</short_desc>
          <delta_ts>2021-09-25 10:03:46 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>2</classification_id>
          <classification>Applications</classification>
          <product>kmail2</product>
          <component>search</component>
          <version>5.16.1</version>
          <rep_platform>Compiled Sources</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="brgreen">xndlcx</reporter>
          <assigned_to name="kdepim bugs">pim-bugs-null</assigned_to>
          <cc>kde_bugtracker</cc>
    
    <cc>montel</cc>
    
    <cc>sknauss</cc>
          
          <cf_commitlink>https://invent.kde.org/pim/akonadi-search/-/commit/518578dc74f5322e122cf79b55d15eb0e13bd34f</cf_commitlink>
          <cf_versionfixedin>5.17.0</cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1630985</commentid>
    <comment_count>0</comment_count>
    <who name="brgreen">xndlcx</who>
    <bug_when>2016-10-10 00:55:10 +0000</bug_when>
    <thetext>Hi - regarding email addresses in the headers of incoming emails. Right-clicking on those already in my Contacts gives the standard &quot;Edit Contact Option&quot;.

But - email addresses with underscores in them are not recognised, and give the options of &quot;Add to Address Book&quot; and &quot;Add to Existing Contact&quot;.

(My first bug report so apologies for any errors, or being put in the wrong location etc...)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1635980</commentid>
    <comment_count>1</comment_count>
    <who name="Laurent Montel">montel</who>
    <bug_when>2016-10-28 06:54:43 +0000</bug_when>
    <thetext>Do you have the problem for other emails ?

could you give me an example as email which doesn&apos;t work ?
Thanks</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1851553</commentid>
    <comment_count>2</comment_count>
    <who name="jc_gargma">kde_bugtracker</who>
    <bug_when>2019-04-21 00:25:30 +0000</bug_when>
    <thetext>I know this is an old bug, but I have this problem as well on kmail 19.04.0
kmail seems unable to correlate an email address to a saved kaddressbook contact when the part before the @ contains an underscore. example_email@example.com
On top of kmail not allowing the edit contact context menu for said address, all other options for the contact linked to that email are not recognized, such as avatar, preferred GnuPG key, and sign/encrypt preferences.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1999828</commentid>
    <comment_count>3</comment_count>
    <who name="Sandro Knauß">sknauss</who>
    <bug_when>2021-02-03 02:27:21 +0000</bug_when>
    <thetext>I can confirm this. It is an issue of the indexer in akonadi-search. I already created a unit test for it:

diff --git a/akonadiplugin/autotests/searchplugintest.cpp b/akonadiplugin/autotests/searchplugintest.cpp
index eb7e84a..fde4500 100644
--- a/akonadiplugin/autotests/searchplugintest.cpp
+++ b/akonadiplugin/autotests/searchplugintest.cpp
@@ -160,7 +160,7 @@ private Q_SLOTS:
             b-&gt;setBody(&quot;body4&quot;);
             msg-&gt;addContent(b, true);
 
-            msg-&gt;from()-&gt;addAddress(&quot;john@test.com&quot;, QStringLiteral(&quot;John Doe&quot;));
+            msg-&gt;from()-&gt;addAddress(&quot;john_rt@test.com&quot;, QStringLiteral(&quot;John Doe&quot;));
             msg-&gt;to()-&gt;addAddress(&quot;jane@test.com&quot;, QStringLiteral(&quot;Jane Doe&quot;));
             msg-&gt;cc()-&gt;addAddress(&quot;cc@test.com&quot;, QStringLiteral(&quot;Jane Doe&quot;));
             msg-&gt;bcc()-&gt;addAddress(&quot;bcc@test.com&quot;, QStringLiteral(&quot;Jane Doe&quot;));
@@ -265,7 +265,8 @@ private Q_SLOTS:
             KContacts::Addressee addressee;
             addressee.setUid(QStringLiteral(&quot;uid2&quot;));
             addressee.setName(QStringLiteral(&quot;Jane Doe&quot;));
-            addressee.setEmails(QStringList() &lt;&lt; QStringLiteral(&quot;jane@test.com&quot;));
+            addressee.setEmails({QStringLiteral(&quot;jane@test.com&quot;),
+                    QStringLiteral(&quot;jane_rt@test.com&quot;)});
 #if QT_VERSION &lt; QT_VERSION_CHECK(5, 15, 0)
             addressee.setBirthday(QDateTime(QDate(2000, 01, 01)));
 #else
@@ -661,6 +662,13 @@ private Q_SLOTS:
             QSet&lt;qint64&gt; result = QSet&lt;qint64&gt;() &lt;&lt; 101 &lt;&lt; 102;
             QTest::newRow(&quot;contact by email&quot;) &lt;&lt; QString::fromLatin1(query.toJSON()) &lt;&lt; collections &lt;&lt; contactMimeTypes &lt;&lt; result;
         }
+        {
+            Akonadi::SearchQuery query;
+            query.addTerm(Akonadi::ContactSearchTerm(Akonadi::ContactSearchTerm::Email, QStringLiteral(&quot;JANE_RT@TEST.COM&quot;), Akonadi::SearchTerm::CondContains));
+            QVector&lt;qint64&gt; collections({3});
+            QSet&lt;qint64&gt; result({101});
+            QTest::newRow(&quot;contact by email2&quot;) &lt;&lt; QString::fromLatin1(query.toJSON()) &lt;&lt; collections &lt;&lt; contactMimeTypes &lt;&lt; result;
+        }
         {
             Akonadi::SearchQuery query;
             query.addTerm(Akonadi::ContactSearchTerm(Akonadi::ContactSearchTerm::Name, QStringLiteral(&quot;Doe&quot;), Akonadi::SearchTerm::CondContains));
@@ -1099,6 +1107,13 @@ private Q_SLOTS:
             QSet&lt;qint64&gt; result = QSet&lt;qint64&gt;() &lt;&lt; 1 &lt;&lt; 2 &lt;&lt; 3 &lt;&lt; 4 &lt;&lt; 5 &lt;&lt; 6;
             QTest::newRow(&quot;search by from email part&quot;) &lt;&lt; QString::fromLatin1(query.toJSON()) &lt;&lt; allEmailCollections &lt;&lt; emailMimeTypes &lt;&lt; result;
         }
+        {
+            Akonadi::SearchQuery query;
+            query.addTerm(Akonadi::EmailSearchTerm(Akonadi::EmailSearchTerm::HeaderFrom, QStringLiteral(&quot;john_rt@test.com&quot;), Akonadi::SearchTerm::CondContains));
+            QSet&lt;qint64&gt; result({4});
+            QTest::newRow(&quot;search by from email part&quot;) &lt;&lt; QString::fromLatin1(query.toJSON()) &lt;&lt; allEmailCollections &lt;&lt; emailMimeTypes &lt;&lt; result;
+        }
+
     }
 
     void testEmailSearch()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2000505</commentid>
    <comment_count>4</comment_count>
    <who name="Sandro Knauß">sknauss</who>
    <bug_when>2021-02-05 19:41:14 +0000</bug_when>
    <thetext>Git commit f87c1644469fc1ebb370f76f40b8f8cc00c6ed15 by Sandro Knauß.
Committed on 05/02/2021 at 19:39.
Pushed by knauss into branch &apos;master&apos;.

SearchPluginTest: Add tests for underscore usage in email addresses.

M  +40   -3    akonadiplugin/autotests/searchplugintest.cpp

https://invent.kde.org/pim/akonadi-search/commit/f87c1644469fc1ebb370f76f40b8f8cc00c6ed15</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2052399</commentid>
    <comment_count>5</comment_count>
    <who name="jc_gargma">kde_bugtracker</who>
    <bug_when>2021-08-09 21:10:12 +0000</bug_when>
    <thetext>I still experience this bug with kmail Version 5.17.3 (21.04.3)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2063877</commentid>
    <comment_count>6</comment_count>
    <who name="Sandro Knauß">sknauss</who>
    <bug_when>2021-09-25 10:03:46 +0000</bug_when>
    <thetext>(In reply to jc_gargma from comment #5)
&gt; I still experience this bug with kmail Version 5.17.3 (21.04.3)

The bug is fixed, but the fix do no trigger a reindex of the contact. So you need to open the editpage of  the contact and press OK, than the contact is reindex and the emailadress with underscore is found afterwards.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>