diff options
| author | Mateusz Polrola <mateusz.polrola@gmail.com> | 2014-08-29 11:42:09 +0200 |
|---|---|---|
| committer | Mateusz Polrola <mateusz.polrola@gmail.com> | 2014-09-08 15:43:04 +0200 |
| commit | 8231f9484281cc424a735799619881bfbc60cd5d (patch) | |
| tree | 19656c93f9bdd543ae8ae26e6cd7332e711abaa3 /tests/libebook-contacts | |
| parent | 0737b9a3e7d65e4746bb309f7732f3213337e23e (diff) | |
| download | evolution-data-server-8231f9484281cc424a735799619881bfbc60cd5d.tar.gz | |
Bug 735659 - EBookSqlite should ignore leading zeros when looking for phone number
EBookSqlite parses phonenumbers using libphonenumber - result of this
operation depends on currently set locale.
Some countries use leading 0 as area code prefix required when number is
presented in national format (without country code) e.g. in United
Kingdom.
This leading zeros may lead to wrong search queries if locale is not set
correctly and number in address book is stored in international format
and search query tries to find it using national format.
For example UK's phone number +44 2033445566 will be stored in user
address book in form - national number: 2033445566, country code: 44.
If user wants to query this number using national format -
02033445566 (with leading zero, e.g. number in such format could be
retrieved from users phone call log) result of operation depends on
currently set locale.
If system locale will be set to en_GB this number will be parsed using
en_GB as default region before making query which will lead to parsing it
into national number 2033445566 and country code 44 (the same like in database).
As EBookSqlite before making query is removing country code from numbers
for which default region was used, search query will look like:
... WHERE (phone_list.value_phone = '2033445566')
which will correctly find contact.
On the other hand the same search query won't return expected result
when system locale will be set to other locale than en_GB, e.g. en_US,
in that case 02033445566 number will be parsed into national number
02033445566 and country code 1, leading to a query
... WHERE (phone_list.value_phone = '02033445566')
Leading zero(s) won't allow to correctly find contact from address book.
EBookSqlite should remove them before making query, but leading
zeros shouldn't be removed from E164 values in contacts vCards.
This change adds additional parameter to
e_phone_number_get_national_number that indicates if leading
zeros should be removed from national number.
EBookSqlite code is updated to use national number without leading zeros
when creating search index.
Diffstat (limited to 'tests/libebook-contacts')
| -rw-r--r-- | tests/libebook-contacts/test-phone-number.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/libebook-contacts/test-phone-number.c b/tests/libebook-contacts/test-phone-number.c index fb4dcbc42..4822fb3ac 100644 --- a/tests/libebook-contacts/test-phone-number.c +++ b/tests/libebook-contacts/test-phone-number.c @@ -200,7 +200,7 @@ test_parse_and_format (gconstpointer data) test_data->country_code); g_assert_cmpuint (source, ==, test_data->country_source); - national = e_phone_number_get_national_number (parsed); + national = e_phone_number_get_national_number (parsed, TRUE); g_assert_cmpstr (national, ==, test_data->national_number); g_free (national); @@ -272,7 +272,7 @@ test_parse_auto_region (void) g_assert_cmpint (e_phone_number_get_country_code (parsed, &source), ==, 1); g_assert_cmpuint (source, ==, E_PHONE_NUMBER_COUNTRY_FROM_DEFAULT); - national = e_phone_number_get_national_number (parsed); + national = e_phone_number_get_national_number (parsed, TRUE); g_assert_cmpstr (national, ==, "2125423789"); g_free (national); |
