summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2015-06-02 07:46:47 +0200
committerMontel Laurent <[email protected]>2015-06-02 07:46:47 +0200
commit1199495cab40da680aa4ffc70c69c5ddf3340142 (patch)
treedc61750c81bb3e5c3fec0042479039dca329d5f9
parentb1682e1088d2db5758fe6b06f37c2c459421f3b5 (diff)
extractEmailAddress can return an empty string if email is not correct
-rw-r--r--mailcommon/search/searchrule/searchrulestring.cpp76
1 files changed, 44 insertions, 32 deletions
diff --git a/mailcommon/search/searchrule/searchrulestring.cpp b/mailcommon/search/searchrule/searchrulestring.cpp
index 4152f11..9221f47 100644
--- a/mailcommon/search/searchrule/searchrulestring.cpp
+++ b/mailcommon/search/searchrule/searchrulestring.cpp
@@ -322,13 +322,16 @@ bool SearchRuleString::matchesInternal( const QString &msgContents ) const
const QStringList addressList = KPIMUtils::splitAddressList( msgContents.toLower() );
QStringList::ConstIterator end( addressList.constEnd() );
for ( QStringList::ConstIterator it = addressList.constBegin(); ( it != end ); ++it ) {
- Akonadi::ContactSearchJob *job = new Akonadi::ContactSearchJob();
- job->setLimit( 1 );
- job->setQuery( Akonadi::ContactSearchJob::Email, KPIMUtils::extractEmailAddress( *it ).toLower() );
- job->exec();
-
- if ( !job->contacts().isEmpty() ) {
- return true;
+ const QString email(KPIMUtils::extractEmailAddress( *it ).toLower());
+ if (!email.isEmpty()) {
+ Akonadi::ContactSearchJob *job = new Akonadi::ContactSearchJob();
+ job->setLimit( 1 );
+ job->setQuery( Akonadi::ContactSearchJob::Email, email );
+ job->exec();
+
+ if ( !job->contacts().isEmpty() ) {
+ return true;
+ }
}
}
return false;
@@ -340,13 +343,16 @@ bool SearchRuleString::matchesInternal( const QString &msgContents ) const
QStringList::ConstIterator end( addressList.constEnd() );
for ( QStringList::ConstIterator it = addressList.constBegin(); ( it != end ); ++it ) {
- Akonadi::ContactSearchJob *job = new Akonadi::ContactSearchJob();
- job->setLimit( 1 );
- job->setQuery( Akonadi::ContactSearchJob::Email, KPIMUtils::extractEmailAddress( *it ).toLower() );
- job->exec();
-
- if ( job->contacts().isEmpty() ) {
- return true;
+ const QString email(KPIMUtils::extractEmailAddress( *it ).toLower());
+ if (!email.isEmpty()) {
+ Akonadi::ContactSearchJob *job = new Akonadi::ContactSearchJob();
+ job->setLimit( 1 );
+ job->setQuery( Akonadi::ContactSearchJob::Email, email );
+ job->exec();
+
+ if ( job->contacts().isEmpty() ) {
+ return true;
+ }
}
}
return false;
@@ -359,15 +365,18 @@ bool SearchRuleString::matchesInternal( const QString &msgContents ) const
QStringList::ConstIterator end( addressList.constEnd() );
for ( QStringList::ConstIterator it = addressList.constBegin(); it != end; ++it ) {
- Akonadi::ContactSearchJob *job = new Akonadi::ContactSearchJob();
- job->setQuery( Akonadi::ContactSearchJob::Email, KPIMUtils::extractEmailAddress( *it ).toLower() );
- job->exec();
-
- const KABC::Addressee::List contacts = job->contacts();
-
- foreach ( const KABC::Addressee &contact, contacts ) {
- if ( contact.hasCategory( category ) ) {
- return true;
+ const QString email(KPIMUtils::extractEmailAddress( *it ).toLower());
+ if (!email.isEmpty()) {
+ Akonadi::ContactSearchJob *job = new Akonadi::ContactSearchJob();
+ job->setQuery( Akonadi::ContactSearchJob::Email, email );
+ job->exec();
+
+ const KABC::Addressee::List contacts = job->contacts();
+
+ foreach ( const KABC::Addressee &contact, contacts ) {
+ if ( contact.hasCategory( category ) ) {
+ return true;
+ }
}
}
}
@@ -381,15 +390,18 @@ bool SearchRuleString::matchesInternal( const QString &msgContents ) const
QStringList::ConstIterator end( addressList.constEnd() );
for ( QStringList::ConstIterator it = addressList.constBegin(); it != end; ++it ) {
- Akonadi::ContactSearchJob *job = new Akonadi::ContactSearchJob();
- job->setQuery( Akonadi::ContactSearchJob::Email, KPIMUtils::extractEmailAddress( *it ).toLower() );
- job->exec();
-
- const KABC::Addressee::List contacts = job->contacts();
-
- foreach ( const KABC::Addressee &contact, contacts ) {
- if ( contact.hasCategory( category ) ) {
- return false;
+ const QString email(KPIMUtils::extractEmailAddress( *it ).toLower());
+ if (!email.isEmpty()) {
+ Akonadi::ContactSearchJob *job = new Akonadi::ContactSearchJob();
+ job->setQuery( Akonadi::ContactSearchJob::Email, email );
+ job->exec();
+
+ const KABC::Addressee::List contacts = job->contacts();
+
+ foreach ( const KABC::Addressee &contact, contacts ) {
+ if ( contact.hasCategory( category ) ) {
+ return false;
+ }
}
}