mirror of
https://github.com/asterisk/asterisk.git
synced 2026-06-29 03:41:34 -07:00
Rework of the commit I made yesterday to use the already built-in
ast_uri_decode function as opposed to my home-rolled one. Also added comments. Thanks to oej for pointing me in the right direction git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@89119 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
+14
-27
@@ -3889,17 +3889,6 @@ static int sip_indicate(struct ast_channel *ast, int condition, const void *data
|
||||
return res;
|
||||
}
|
||||
|
||||
static char *translate_escaped_pound(char *exten)
|
||||
{
|
||||
char *rest, *marker;
|
||||
while((marker = strstr(exten, "%23"))) {
|
||||
rest = marker + 3;
|
||||
*marker++ = '#';
|
||||
memmove(marker, rest, strlen(rest) + 1);
|
||||
}
|
||||
return exten;
|
||||
}
|
||||
|
||||
|
||||
/*! \brief Initiate a call in the SIP channel
|
||||
called from sip_request_call (calls from the pbx ) for outbound channels
|
||||
@@ -3913,6 +3902,7 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
|
||||
int fmt;
|
||||
int what;
|
||||
int needvideo = 0, video = 0;
|
||||
char *decoded_exten;
|
||||
{
|
||||
const char *my_name; /* pick a good name */
|
||||
|
||||
@@ -4025,7 +4015,13 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
|
||||
i->owner = tmp;
|
||||
ast_module_ref(ast_module_info->self);
|
||||
ast_copy_string(tmp->context, i->context, sizeof(tmp->context));
|
||||
ast_copy_string(tmp->exten, translate_escaped_pound(ast_strdupa(i->exten)), sizeof(tmp->exten));
|
||||
/*Since it is valid to have extensions in the dialplan that have unescaped characters in them
|
||||
* we should decode the uri before storing it in the channel, but leave it encoded in the sip_pvt
|
||||
* structure so that there aren't issues when forming URI's
|
||||
*/
|
||||
decoded_exten = ast_strdupa(i->exten);
|
||||
ast_uri_decode(decoded_exten);
|
||||
ast_copy_string(tmp->exten, decoded_exten, sizeof(tmp->exten));
|
||||
|
||||
/* Don't use ast_set_callerid() here because it will
|
||||
* generate an unnecessary NewCallerID event */
|
||||
@@ -8729,26 +8725,17 @@ static int get_destination(struct sip_pvt *p, struct sip_request *oreq)
|
||||
} else {
|
||||
/* Check the dialplan for the username part of the request URI,
|
||||
the domain will be stored in the SIPDOMAIN variable
|
||||
Since extensions.conf can have unescaped characters, try matching a decoded
|
||||
uri in addition to the non-decoded uri
|
||||
Return 0 if we have a matching extension */
|
||||
if (ast_exists_extension(NULL, p->context, uri, 1, S_OR(p->cid_num, from)) ||
|
||||
char *decoded_uri = ast_strdupa(uri);
|
||||
ast_uri_decode(decoded_uri);
|
||||
if (ast_exists_extension(NULL, p->context, uri, 1, S_OR(p->cid_num, from)) || ast_exists_extension(NULL, p->context, decoded_uri, 1, S_OR(p->cid_num, from)) ||
|
||||
!strcmp(uri, ast_pickup_ext())) {
|
||||
if (!oreq)
|
||||
ast_string_field_set(p, exten, uri);
|
||||
return 0;
|
||||
} else { /*Could be trying to match a literal '#'. Try replacing and see if that works.*/
|
||||
char *tmpuri = ast_strdupa(uri);
|
||||
char *rest, *marker;
|
||||
while((marker = strstr(tmpuri, "%23"))) {
|
||||
rest = marker + 3;
|
||||
*marker++ = '#';
|
||||
memmove(marker, rest, strlen(rest) + 1);
|
||||
}
|
||||
if(ast_exists_extension(NULL, p->context, tmpuri, 1, from) || !strcmp(uri, ast_pickup_ext())) {
|
||||
if(!oreq)
|
||||
ast_string_field_set(p, exten, uri);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Return 1 for pickup extension or overlap dialling support (if we support it) */
|
||||
|
||||
Reference in New Issue
Block a user