diff --git a/coreapi/lpconfig.c b/coreapi/lpconfig.c index f96966eac..680198cd3 100644 --- a/coreapi/lpconfig.c +++ b/coreapi/lpconfig.c @@ -497,10 +497,10 @@ void lp_config_set_string(LpConfig *lpconfig,const char *section, const char *ke lp_item_set_value(item,value); else lp_section_remove_item(sec,item); }else{ - if (value!=NULL) + if (value!=NULL && value[0] != '\0') lp_section_add_item(sec,lp_item_new(key,value)); } - }else if (value!=NULL){ + }else if (value!=NULL && value[0] != '\0'){ sec=lp_section_new(section); lp_config_add_section(lpconfig,sec); lp_section_add_item(sec,lp_item_new(key,value)); diff --git a/coreapi/private.h b/coreapi/private.h index ef876ae7d..c993fc89a 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -246,7 +246,7 @@ struct _LinphoneCall bool_t playing_ringbacktone; bool_t ringing_beep; /* whether this call is ringing through an already existent current call*/ bool_t auth_token_verified; - + bool_t defer_update; bool_t was_automatically_paused; bool_t ping_replied; @@ -482,8 +482,8 @@ typedef enum _LinphoneIsComposingState { } LinphoneIsComposingState; struct _LinphoneChatRoom{ - belle_sip_object_t base; - void *user_data; + belle_sip_object_t base; + void *user_data; struct _LinphoneCore *lc; char *peer; LinphoneAddress *peer_url; @@ -886,7 +886,7 @@ void linphone_core_invalidate_friend_subscriptions(LinphoneCore *lc); void linphone_configuring_terminated(LinphoneCore *lc, LinphoneConfiguringState state, const char *message); int linphone_remote_provisioning_download_and_apply(LinphoneCore *lc, const char *remote_provisioning_uri); - +int linphone_remote_provisioning_load_file( LinphoneCore* lc, const char* file_path); /***************************************************************************** * Player interface diff --git a/coreapi/remote_provisioning.c b/coreapi/remote_provisioning.c index 1b081a354..fd5d2eb92 100644 --- a/coreapi/remote_provisioning.c +++ b/coreapi/remote_provisioning.c @@ -60,7 +60,7 @@ static void linphone_remote_provisioning_apply(LinphoneCore *lc, const char *xml , error_msg); } -static int linphone_remote_provisioning_load_file( LinphoneCore* lc, const char* file_path){ +int linphone_remote_provisioning_load_file( LinphoneCore* lc, const char* file_path){ int status = -1; FILE* f = fopen(file_path, "r"); diff --git a/tester/rcfiles/remote_zero_length_params_rc b/tester/rcfiles/remote_zero_length_params_rc new file mode 100644 index 000000000..915722787 --- /dev/null +++ b/tester/rcfiles/remote_zero_length_params_rc @@ -0,0 +1,7 @@ + + +
+ + test +
+
diff --git a/tester/setup_tester.c b/tester/setup_tester.c index 6d0631235..698e3429f 100644 --- a/tester/setup_tester.c +++ b/tester/setup_tester.c @@ -143,6 +143,29 @@ static void linphone_lpconfig_from_file_zerolen_value(){ lp_config_destroy(conf); } +static void linphone_lpconfig_from_xml_zerolen_value(){ + static const char* zero_xml_file = "remote_zero_length_params_rc"; + char* xml_path = ms_strdup_printf("%s/rcfiles/%s", liblinphone_tester_file_prefix, zero_xml_file); + LpConfig* conf; + + LinphoneCoreManager* mgr = linphone_core_manager_new2("empty_rc",FALSE); + + CU_ASSERT_EQUAL(linphone_remote_provisioning_load_file(mgr->lc, xml_path), 0); + + conf = mgr->lc->config; + + ms_error("ZERO: %s", lp_config_get_string(conf,"test","zero_len","LOL")); + + CU_ASSERT_STRING_EQUAL(lp_config_get_string(conf,"test","zero_len","LOL"),"LOL"); + CU_ASSERT_STRING_EQUAL(lp_config_get_string(conf,"test","non_zero_len",""),"test"); + + lp_config_set_string(conf, "test", "non_zero_len", ""); /* should remove "non_zero_len" */ + CU_ASSERT_STRING_EQUAL(lp_config_get_string(conf,"test","non_zero_len","LOL"), "LOL"); + + linphone_core_manager_destroy(mgr); + +} + void linphone_proxy_config_address_equal_test() { LinphoneAddress *a = linphone_address_new("sip:toto@titi"); LinphoneAddress *b = linphone_address_new("sips:toto@titi"); @@ -226,6 +249,7 @@ test_t setup_tests[] = { { "LPConfig from buffer", linphone_lpconfig_from_buffer }, { "LPConfig zero_len value from buffer", linphone_lpconfig_from_buffer_zerolen_value }, { "LPConfig zero_len value from file", linphone_lpconfig_from_file_zerolen_value }, + { "LPConfig zero_len value from XML", linphone_lpconfig_from_xml_zerolen_value }, { "Chat room", chat_root_test } };