Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
[libcontacts] Do not search for empty values
If we search for values without first testing that they are valid, we
will match any invalid data items that have been created.
  • Loading branch information
matthewvogt committed Dec 31, 2013
1 parent fd74456 commit abcec4b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/seasidecache.cpp
Expand Up @@ -1346,8 +1346,12 @@ static QContactFilter filterForMergeCandidates(const QContact &contact)
}

// Phone number match
foreach (const QContactPhoneNumber &number, contact.details<QContactPhoneNumber>()) {
rv = rv | QContactPhoneNumber::match(number.number());
foreach (const QContactPhoneNumber &phoneNumber, contact.details<QContactPhoneNumber>()) {
const QString number(phoneNumber.number());
if (number.isEmpty())
continue;

rv = rv | QContactPhoneNumber::match(number);
}

// Email address match
Expand All @@ -1359,6 +1363,9 @@ static QContactFilter filterForMergeCandidates(const QContact &contact)
address = address.left(index);
}

if (address.isEmpty())
continue;

QContactDetailFilter filter;
setDetailType<QContactEmailAddress>(filter, QContactEmailAddress::FieldEmailAddress);
filter.setMatchFlags((index > 0 ? QContactFilter::MatchStartsWith : QContactFilter::MatchExactly) | QContactFilter::MatchFixedString);
Expand All @@ -1375,6 +1382,9 @@ static QContactFilter filterForMergeCandidates(const QContact &contact)
uri = uri.left(index);
}

if (uri.isEmpty())
continue;

QContactDetailFilter filter;
setDetailType<QContactOnlineAccount>(filter, QContactOnlineAccount::FieldAccountUri);
filter.setMatchFlags((index > 0 ? QContactFilter::MatchStartsWith : QContactFilter::MatchExactly) | QContactFilter::MatchFixedString);
Expand Down

0 comments on commit abcec4b

Please sign in to comment.