Commit 819e0f07 authored by Gautier Pelloux-Prayer's avatar Gautier Pelloux-Prayer
Browse files

proxy: fix normalize_number when having invalid prefix dial code

parent 1bd8a6ad
......@@ -948,17 +948,13 @@ bool_t linphone_proxy_config_normalize_number(LinphoneProxyConfig *inproxy, cons
if (linphone_proxy_config_is_phone_number(proxy, username)){
dial_plan_t dialplan = {0};
char *flatten=flatten_number(username);
bool_t dialplan_found = FALSE;
ms_debug("Flattened number is '%s'",flatten);
/*username does not contain a dial prefix nor the proxy, nothing else to do*/
if (proxy->dial_prefix==NULL || proxy->dial_prefix[0]=='\0'){
strncpy(result,flatten,result_len-1);
} else {
dialplan_found = lookup_dial_plan_by_ccc(proxy->dial_prefix,&dialplan);
}
if (dialplan_found) {
lookup_dial_plan_by_ccc(proxy->dial_prefix,&dialplan);
ms_debug("Using dial plan '%s'",dialplan.country);
/* the number has international prefix or +, so nothing to do*/
if (flatten[0]=='+'){
......@@ -1000,6 +996,7 @@ bool_t linphone_proxy_config_normalize_number(LinphoneProxyConfig *inproxy, cons
strncpy(result+i,flatten+skip,result_len-i-1);
}
}
ms_free(flatten);
ret = TRUE;
} else {
......
......@@ -51,6 +51,12 @@ static void phone_normalization_with_proxy() {
BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "01 2345678"), "+33012345678");
BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "01234567891"), "+33234567891"); // invalid phone number (too long)
BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "I_AM_NOT_A_NUMBER"), "I_AM_NOT_A_NUMBER"); // invalid phone number
BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+990012345678"), "+990012345678");
linphone_proxy_config_set_dial_prefix(proxy, "99");
BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "0012345678"), "+12345678");
linphone_proxy_config_destroy(proxy);
}
......
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