aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2010-09-21 21:58:13 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2010-09-21 21:58:13 +0000
commit8262f5128f7dd566669b6269a2bfb6ec5b2dd6c8 (patch)
tree1c7e9438de615921851b62df88b84d79bf559d3e /channels
parentfb3a7d23f2beab627cc0fef5d1c8c4a230f37c79 (diff)
Try both the encoded and unencoded subscription URI for a match in hints.
When a phone sends an encoded URI for a subscription, the URI is not matched with the actual hint that is in decoded format. For example, if we have an extension with a hint that is named: "#5601" or "*5601", the subscription will work fine if the phone subscribes with an already decoded URI, but when it's decoded like "%255601" or "%2A5601", Asterisk is unable to match it with the correct hint. (closes issue #17785) Reported by: ramonpeek Patches: 20100831__issue17785.diff.txt uploaded by tilghman (license 14) Tested by: ramonpeek git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@288112 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 3aedc0a70..aac35178e 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -9905,24 +9905,37 @@ static int get_destination(struct sip_pvt *p, struct sip_request *oreq)
if (sip_debug_test_pvt(p))
ast_verbose("Looking for %s in %s (domain %s)\n", uri, p->context, p->domain);
+ /* Since extensions.conf can have unescaped characters, try matching a
+ * decoded uri in addition to the non-decoded uri. */
+ decoded_uri = ast_strdupa(uri);
+ ast_uri_decode(decoded_uri);
+
/* If this is a subscription we actually just need to see if a hint exists for the extension */
if (req->method == SIP_SUBSCRIBE) {
char hint[AST_MAX_EXTENSION];
- return (ast_get_hint(hint, sizeof(hint), NULL, 0, NULL, p->context, p->exten) ? 0 : -1);
+ int which = 0;
+ if (ast_get_hint(hint, sizeof(hint), NULL, 0, NULL, p->context, uri) ||
+ (ast_get_hint(hint, sizeof(hint), NULL, 0, NULL, p->context, decoded_uri) && (which = 1))) {
+ if (!oreq) {
+ ast_string_field_set(p, exten, which ? decoded_uri : uri);
+ }
+ return 0;
+ } else {
+ return -1;
+ }
} else {
- decoded_uri = ast_strdupa(uri);
- ast_uri_decode(decoded_uri);
+ int which = 0;
/* 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)) || ast_exists_extension(NULL, p->context, decoded_uri, 1, S_OR(p->cid_num, from)) ||
+ 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)) && (which = 1)) ||
!strcmp(decoded_uri, ast_pickup_ext())) {
- if (!oreq)
- ast_string_field_set(p, exten, decoded_uri);
+ if (!oreq) {
+ ast_string_field_set(p, exten, which ? decoded_uri : uri);
+ }
return 0;
- }
+ }
}
/* Return 1 for pickup extension or overlap dialling support (if we support it) */