Commit abcec4b2 authored by mvogt's avatar mvogt

[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.
parent fd744560
......@@ -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
......@@ -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);
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment