Commit fc79ebb0 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Fixed various issues related to username with escaped character

parent d36e1330
......@@ -110,10 +110,13 @@ static char* _get_identity(const LinphoneAccountCreator *creator) {
addr = linphone_proxy_config_normalize_sip_uri(proxy, creator->username ? creator->username : creator->phone_number);
if (addr == NULL || (creator->domain && strcmp(linphone_address_get_domain(addr), creator->domain) != 0)) {
if ((creator->username || creator->phone_number) && creator->domain) {
char *url = ms_strdup_printf("sip:%s@%s", creator->username ? creator->username : creator->phone_number, creator->domain);
char *url = ms_strdup_printf("sip:%s", creator->domain);
addr = linphone_address_new(url);
ms_free(url);
if (addr == NULL) {
if (addr) {
linphone_address_set_username(addr, creator->username ? creator->username : creator->phone_number);
} else {
goto end;
}
} else {
......
......@@ -402,7 +402,7 @@ belle_sdp_session_description_t * media_description_to_sdp ( const SalMediaDescr
} else inet6=0;
belle_sdp_session_description_set_version ( session_desc,belle_sdp_version_create ( 0 ) );
origin = belle_sdp_origin_create ( desc->username
origin = belle_sdp_origin_create ( belle_sip_uri_to_escaped_username(desc->username)
,desc->session_id
,desc->session_ver
,"IN"
......
......@@ -104,13 +104,7 @@ Address::Address (const IdentityAddress &identityAddress) : ClonableObject(*new
if (domain.empty())
return;
string uri = identityAddress.getScheme() + ":" + username + "@" + (
domain.find(':') != string::npos ? "[" + domain + "]" : domain
);
if (identityAddress.hasGruu())
uri += ";gr=" + identityAddress.getGruu();
string uri = identityAddress.asString();
d->internalAddress = getSalAddressFromCache(uri);
}
......
......@@ -17,6 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <belle-sip/utils.h>
#include "linphone/utils/utils.h"
#include "address.h"
......@@ -50,7 +51,7 @@ IdentityAddress::IdentityAddress (const string &address) : ClonableObject(*new I
shared_ptr<IdentityAddress> parsedAddress = IdentityAddressParser::getInstance()->parseAddress(address);
if (parsedAddress != nullptr) {
d->scheme = parsedAddress->getScheme();
d->username = parsedAddress->getUsername();
d->username = belle_sip_to_unescaped_string(parsedAddress->getUsername().c_str());
d->domain = parsedAddress->getDomain();
d->gruu = parsedAddress->getGruu();
} else {
......@@ -180,7 +181,7 @@ string IdentityAddress::asString () const {
ostringstream res;
res << d->scheme << ":";
if (!d->username.empty()){
res << d->username << "@";
res << belle_sip_uri_to_escaped_username(d->username.c_str()) << "@";
}
if (d->domain.find(":") != string::npos) {
......
......@@ -637,6 +637,7 @@ static void group_chat_room_creation_server (void) {
wait_for_list(coresList, &dummy, 1, 1000);
// Chloe begins composing a message
BC_ASSERT_PTR_NOT_NULL(chloeCr);
linphone_chat_room_compose(chloeCr);
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneIsComposingActiveReceived, initialMarieStats.number_of_LinphoneIsComposingActiveReceived + 1, 3000));
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneIsComposingActiveReceived, initialPaulineStats.number_of_LinphoneIsComposingActiveReceived + 1, 3000));
......
......@@ -13,8 +13,8 @@ store_ha1_passwd=0 #used for sipp
zrtp_cache_migration_done=1
[auth_info_0]
username=marie
userid=marie
username=marie laroueverte
userid=marie laroueverte
passwd=secret
realm=sip.example.org
......@@ -24,7 +24,7 @@ algorithm=SHA-256
[proxy_0]
reg_proxy=sip.example.org;transport=tcp
reg_route=sip.example.org;transport=tcp;lr
reg_identity="Super Marie" <sip:marie@sip.example.org>
reg_identity="Super Marie" <sip:marie%20laroueverte@sip.example.org>
reg_expires=3600
reg_sendregister=1
publish=0
......
......@@ -8,15 +8,15 @@ composing_idle_timeout=1
store_ha1_passwd=0 #used for sipp
[auth_info_0]
username=marie
userid=marie
username=marie laroueverte
userid=marie laroueverte
passwd=secret
realm=sip.example.org
[proxy_0]
reg_proxy=<sip:sip.example.org;transport=tcp>
reg_route=<sip:sip.example.org;transport=tcp>
reg_identity="Super Marie" <sip:marie@sip.example.org>
reg_identity="Super Marie" <sip:marie%20laroueverte@sip.example.org>
reg_expires=3600
reg_sendregister=1
publish=0
......
......@@ -93,6 +93,21 @@ static void core_init_test(void) {
}
}
static void core_init_test_2(void) {
LinphoneCore* lc;
char* rc_path = bc_tester_res("rcfiles/chloe_rc");
lc = linphone_factory_create_core_2(linphone_factory_get(),NULL,NULL, rc_path, NULL, system_context);
/* until we have good certificates on our test server... */
linphone_core_verify_server_certificates(lc,FALSE);
if (BC_ASSERT_PTR_NOT_NULL(lc)) {
BC_ASSERT_EQUAL(linphone_core_get_global_state(lc), LinphoneGlobalOn, int, "%i");
BC_ASSERT_PTR_NOT_NULL(linphone_core_get_default_proxy_config(lc));
linphone_core_unref(lc);
}
ms_free(rc_path);
}
static void core_init_stop_test(void) {
LinphoneCore* lc;
lc = linphone_factory_create_core_2(linphone_factory_get(),NULL,NULL,liblinphone_tester_get_empty_rc(), NULL, system_context);
......@@ -143,6 +158,13 @@ static void linphone_address_test(void) {
linphone_address_unref(create_linphone_address(NULL));
BC_ASSERT_PTR_NULL(linphone_address_new("sip:@sip.linphone.org"));
linphone_address_unref(create_linphone_address(NULL));
BC_ASSERT_PTR_NULL(linphone_address_new("sip:paul ine@sip.linphone.org"));
address = linphone_address_new("sip:paul%20ine@90.110.127.31");
if (!BC_ASSERT_PTR_NOT_NULL(address)) return;
linphone_address_unref(address);
address = linphone_address_new("sip:90.110.127.31");
if (!BC_ASSERT_PTR_NOT_NULL(address)) return;
linphone_address_unref(address);
......@@ -225,6 +247,22 @@ static void linphone_interpret_url_test(void) {
linphone_address_unref(address);
ms_free(tmp);
address = linphone_core_interpret_url(lc,"paul ine");
BC_ASSERT_PTR_NOT_NULL(address);
BC_ASSERT_STRING_EQUAL(linphone_address_get_scheme(address), "sip");
BC_ASSERT_STRING_EQUAL(linphone_address_get_username(address), "paul ine");
BC_ASSERT_STRING_EQUAL(linphone_address_get_domain(address), "sip.linphone.org");
tmp = linphone_address_as_string(address);
BC_ASSERT_TRUE(strcmp (tmp,"sip:paul%20ine@sip.linphone.org") == 0);
linphone_address_unref(address);
address = linphone_core_interpret_url(lc,tmp);
BC_ASSERT_STRING_EQUAL(linphone_address_get_scheme(address), "sip");
BC_ASSERT_STRING_EQUAL(linphone_address_get_username(address), "paul ine");
BC_ASSERT_STRING_EQUAL(linphone_address_get_domain(address), "sip.linphone.org");
linphone_address_unref(address);
ms_free(tmp);
linphone_core_unref(lc);
}
......@@ -1615,6 +1653,7 @@ test_t setup_tests[] = {
TEST_NO_TAG("Linphone proxy config address equal (internal api)", linphone_proxy_config_address_equal_test),
TEST_NO_TAG("Linphone proxy config server address change (internal api)", linphone_proxy_config_is_server_config_changed_test),
TEST_NO_TAG("Linphone core init/uninit", core_init_test),
TEST_NO_TAG("Linphone core init/uninit from existing rc", core_init_test_2),
TEST_NO_TAG("Linphone core init/stop/uninit", core_init_stop_test),
TEST_NO_TAG("Linphone core init/stop/start/uninit", core_init_stop_start_test),
TEST_NO_TAG("Linphone random transport port",core_sip_transport_test),
......
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