Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 110624) +++ channels/chan_sip.c (working copy) @@ -10589,7 +10589,7 @@ */ static int get_destination(struct sip_pvt *p, struct sip_request *oreq) { - char tmp[256] = "", *uri, *a; + char tmp[256] = "", *uri, *decoded_uri, *a; char tmpf[256] = "", *from = NULL; struct sip_request *req; char *colon; @@ -10659,6 +10659,9 @@ *colon = '\0'; uri = strsep(&uri, ";"); /* Remove userinfo options */ + decoded_uri = ast_strdupa(uri); + ast_uri_decode(decoded_uri); + a = strsep(&a, ";"); /* Remove URI options */ ast_string_field_set(p, domain, a); @@ -10695,20 +10698,18 @@ 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 */ - 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 (ast_exists_extension(NULL, p->context, decoded_uri, 1, S_OR(p->cid_num, from)) || + !strcmp(decoded_uri, ast_pickup_ext())) { if (!oreq) - ast_string_field_set(p, exten, uri); + ast_string_field_set(p, exten, decoded_uri); return 0; } } /* Return 1 for pickup extension or overlap dialling support (if we support it) */ if((ast_test_flag(&global_flags[1], SIP_PAGE2_ALLOWOVERLAP) && - ast_canmatch_extension(NULL, p->context, uri, 1, S_OR(p->cid_num, from))) || - !strncmp(uri, ast_pickup_ext(), strlen(uri))) { + ast_canmatch_extension(NULL, p->context, decoded_uri, 1, S_OR(p->cid_num, from))) || + !strncmp(decoded_uri, ast_pickup_ext(), strlen(decoded_uri))) { return 1; }