fix uri nonsense and backwards stristr
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6274 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
7c24fffcde
commit
a62373c784
|
@ -301,7 +301,7 @@ SWITCH_DECLARE(unsigned int) switch_separate_string(char *buf, char delim, char
|
|||
SWITCH_DECLARE(switch_bool_t) switch_is_number(const char *str);
|
||||
SWITCH_DECLARE(char *) switch_strip_spaces(const char *str);
|
||||
SWITCH_DECLARE(char *) switch_separate_paren_args(char *str);
|
||||
SWITCH_DECLARE(const char *) switch_stristr(const char *str, const char *instr);
|
||||
SWITCH_DECLARE(const char *) switch_stristr(const char *instr, const char *str);
|
||||
SWITCH_DECLARE(switch_bool_t) switch_is_lan_addr(const char *ip);
|
||||
SWITCH_DECLARE(char *) switch_replace_char(char *str, char from, char to, switch_bool_t dup);
|
||||
SWITCH_DECLARE(switch_bool_t) switch_ast2regex(char *pat, char *rbuf, size_t len);
|
||||
|
|
|
@ -1337,7 +1337,7 @@ SWITCH_STANDARD_APP(audio_bridge_function)
|
|||
if the variable continue_on_fail is set it can be:
|
||||
'true' to continue on all failures.
|
||||
'false' to not continue.
|
||||
A list of codes either names or numbers eg "user_busy,normal_temporary_failure"
|
||||
A list of codes either names or numbers eg "user_busy,normal_temporary_failure,603"
|
||||
*/
|
||||
if (continue_on_fail) {
|
||||
const char *cause_str;
|
||||
|
@ -1346,7 +1346,7 @@ SWITCH_STANDARD_APP(audio_bridge_function)
|
|||
cause_str = switch_channel_cause2str(cause);
|
||||
snprintf(cause_num, sizeof(cause_num), "%u", cause);
|
||||
|
||||
if (switch_true(continue_on_fail) || switch_stristr(cause_str, continue_on_fail) || strstr(cause_str, cause_num)) {
|
||||
if (switch_true(continue_on_fail) || switch_stristr(cause_str, continue_on_fail) || strstr(cause_num, continue_on_fail)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Continue on fail [%s]: Cause: %s\n", continue_on_fail, cause_str);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -481,6 +481,7 @@ char *sofia_glue_get_url_from_contact(char *buf, uint8_t to_dup);
|
|||
void sofia_presence_set_hash_key(char *hash_key, int32_t len, sip_t const *sip);
|
||||
void sofia_glue_sql_close(sofia_profile_t *profile);
|
||||
int sofia_glue_init_sql(sofia_profile_t *profile);
|
||||
char *sofia_overcome_sip_uri_weakness(switch_core_session_t *session, const char *uri, const char *transport);
|
||||
switch_bool_t sofia_glue_execute_sql_callback(sofia_profile_t *profile,
|
||||
switch_bool_t master,
|
||||
switch_mutex_t *mutex,
|
||||
|
|
|
@ -470,6 +470,34 @@ switch_status_t sofia_glue_tech_choose_video_port(private_object_t *tech_pvt)
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
char *sofia_overcome_sip_uri_weakness(switch_core_session_t *session, const char *uri, const char *transport)
|
||||
{
|
||||
char *stripped = switch_core_session_strdup(session, uri);
|
||||
char *new_uri = NULL;
|
||||
|
||||
stripped = sofia_glue_get_url_from_contact(stripped, 0);
|
||||
if (transport && strcasecmp(transport, "udp")) {
|
||||
if (switch_stristr("port=", stripped)) {
|
||||
new_uri = switch_core_session_sprintf(session, "<%s>", stripped);
|
||||
} else {
|
||||
if (strchr(stripped, ';')) {
|
||||
new_uri = switch_core_session_sprintf(session, "<%s&transport=%s>", stripped, transport);
|
||||
} else {
|
||||
new_uri = switch_core_session_sprintf(session, "<%s;transport=%s>", stripped, transport);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
char *p;
|
||||
if ((p = strrchr(stripped, ';'))) {
|
||||
*p = '\0';
|
||||
}
|
||||
new_uri = stripped;
|
||||
}
|
||||
|
||||
return new_uri;
|
||||
}
|
||||
|
||||
|
||||
switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
||||
{
|
||||
char *rpid = NULL;
|
||||
|
@ -562,7 +590,6 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
|||
sofia_private_t *sofia_private;
|
||||
char *invite_contact = NULL, *to_str, *use_from_str, *from_str, *url_str;
|
||||
const char *transport = "udp", *t_var;
|
||||
char *d_contact = NULL;
|
||||
|
||||
if (switch_strlen_zero(tech_pvt->dest)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "URL Error! [%s]\n", tech_pvt->dest);
|
||||
|
@ -586,7 +613,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
|||
} else {
|
||||
use_from_str = tech_pvt->from_str;
|
||||
}
|
||||
|
||||
|
||||
if (switch_stristr("port=tcp", url)) {
|
||||
transport = "tcp";
|
||||
} else {
|
||||
|
@ -595,33 +622,13 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
|||
transport = t_var;
|
||||
}
|
||||
}
|
||||
url_str = switch_core_session_sprintf(session, "%s;transport=%s", url, transport);
|
||||
}
|
||||
|
||||
d_contact = sofia_glue_get_url_from_contact(tech_pvt->invite_contact, 1);
|
||||
|
||||
if (switch_stristr("port=", d_contact)) {
|
||||
invite_contact = switch_core_session_sprintf(session, "<%s>", d_contact);
|
||||
} else {
|
||||
if (strchr(d_contact, ';')) {
|
||||
invite_contact = switch_core_session_sprintf(session, "<%s&transport=%s>", d_contact, transport);
|
||||
} else {
|
||||
invite_contact = switch_core_session_sprintf(session, "%s;transport=%s", d_contact, transport);
|
||||
}
|
||||
}
|
||||
|
||||
if (strchr(use_from_str, '>')) {
|
||||
from_str = switch_core_session_sprintf(session, "%s;transport=%s", use_from_str, transport);
|
||||
} else {
|
||||
from_str = switch_core_session_sprintf(session, "<%s;transport=%s>", use_from_str, transport);
|
||||
}
|
||||
|
||||
if (strchr(tech_pvt->dest_to, '>')) {
|
||||
to_str = switch_core_session_sprintf(session, "%s;transport=%s", tech_pvt->dest_to, transport);
|
||||
} else {
|
||||
to_str = switch_core_session_sprintf(session, "<%s;transport=%s>", tech_pvt->dest_to, transport);
|
||||
}
|
||||
|
||||
url_str = sofia_overcome_sip_uri_weakness(session, url, transport);
|
||||
invite_contact = sofia_overcome_sip_uri_weakness(session, tech_pvt->invite_contact, transport);
|
||||
from_str = sofia_overcome_sip_uri_weakness(session, use_from_str, NULL);
|
||||
to_str = sofia_overcome_sip_uri_weakness(session, tech_pvt->dest_to, NULL);
|
||||
|
||||
tech_pvt->nh = nua_handle(tech_pvt->profile->nua, NULL,
|
||||
NUTAG_URL(url_str),
|
||||
SIPTAG_TO_STR(to_str),
|
||||
|
@ -630,7 +637,6 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
|||
TAG_END());
|
||||
|
||||
switch_safe_free(d_url);
|
||||
switch_safe_free(d_contact);
|
||||
|
||||
if (!(sofia_private = malloc(sizeof(*sofia_private)))) {
|
||||
abort();
|
||||
|
|
|
@ -155,7 +155,7 @@ char *sofia_presence_translate_rpid(char *in, char *ext)
|
|||
{
|
||||
char *r = in;
|
||||
|
||||
if (in && (switch_stristr(in, "null"))) {
|
||||
if (in && (switch_stristr("null", in))) {
|
||||
in = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -334,7 +334,7 @@ SWITCH_DECLARE(switch_bool_t) switch_is_number(const char *str)
|
|||
}
|
||||
|
||||
|
||||
SWITCH_DECLARE(const char *) switch_stristr(const char *str, const char *instr)
|
||||
SWITCH_DECLARE(const char *) switch_stristr(const char *instr, const char *str)
|
||||
{
|
||||
/*
|
||||
** Rev History: 16/07/97 Greg Thayer Optimized
|
||||
|
|
|
@ -1018,7 +1018,7 @@ static int preprocess(const char *cwd, const char *file, int write_fd, int rleve
|
|||
}
|
||||
}
|
||||
|
||||
if ((tcmd = (char *)switch_stristr(bp, "<X-pre-process"))) {
|
||||
if ((tcmd = (char *)switch_stristr("<X-pre-process", bp))) {
|
||||
if ((e = strstr(tcmd, "/>"))) {
|
||||
*e += 2;
|
||||
*e = '\0';
|
||||
|
@ -1027,15 +1027,15 @@ static int preprocess(const char *cwd, const char *file, int write_fd, int rleve
|
|||
}
|
||||
}
|
||||
|
||||
if (!(tcmd = (char *)switch_stristr(tcmd, "cmd"))) {
|
||||
if (!(tcmd = (char *)switch_stristr("cmd", tcmd))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(tcmd = (char *)switch_stristr(tcmd, "="))) {
|
||||
if (!(tcmd = (char *)switch_stristr("=", tcmd))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(tcmd = (char *)switch_stristr(tcmd, "\""))) {
|
||||
if (!(tcmd = (char *)switch_stristr("\"", tcmd))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1046,15 +1046,15 @@ static int preprocess(const char *cwd, const char *file, int write_fd, int rleve
|
|||
*e++ = '\0';
|
||||
}
|
||||
|
||||
if (!(targ = (char *)switch_stristr(e, "data"))) {
|
||||
if (!(targ = (char *)switch_stristr("data", e))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(targ = (char *)switch_stristr(targ, "="))) {
|
||||
if (!(targ = (char *)switch_stristr("=", targ))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(targ = (char *)switch_stristr(targ, "\""))) {
|
||||
if (!(targ = (char *)switch_stristr("\"", targ))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1694,7 +1694,7 @@ SWITCH_DECLARE(void) switch_xml_free(switch_xml_t xml)
|
|||
}
|
||||
|
||||
if (xml->free_path) {
|
||||
if (!switch_stristr(xml->free_path, ".fsxml")) {
|
||||
if (!switch_stristr(".fsxml", xml->free_path)) {
|
||||
unlink(xml->free_path);
|
||||
}
|
||||
switch_safe_free(xml->free_path);
|
||||
|
|
Loading…
Reference in New Issue