Index: apps/app_dial.c =================================================================== --- apps/app_dial.c (revision 307141) +++ apps/app_dial.c (working copy) @@ -2488,14 +2488,26 @@ gosub_argstart = strchr(opt_args[OPT_ARG_CALLEE_GOSUB], ','); if (gosub_argstart) { + const char *what_is_s = "s"; *gosub_argstart = 0; - if (asprintf(&gosub_args, "%s,s,1(%s)", opt_args[OPT_ARG_CALLEE_GOSUB], gosub_argstart + 1) < 0) { + if (!ast_exists_extension(peer, opt_args[OPT_ARG_CALLEE_GOSUB], "s", 1, S_COR(peer->caller.id.number.valid, peer->caller.id.number.str, NULL)) && + ast_exists_extension(peer, opt_args[OPT_ARG_CALLEE_GOSUB], "~~s~~", 1, S_COR(peer->caller.id.number.valid, peer->caller.id.number.str, NULL))) { + what_is_s = "~~s~~"; + ast_copy_string(peer->exten, "~~s~~", sizeof(peer->exten)); + } + if (asprintf(&gosub_args, "%s,%s,1(%s)", opt_args[OPT_ARG_CALLEE_GOSUB], what_is_s, gosub_argstart + 1) < 0) { ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno)); gosub_args = NULL; } *gosub_argstart = ','; } else { - if (asprintf(&gosub_args, "%s,s,1", opt_args[OPT_ARG_CALLEE_GOSUB]) < 0) { + const char *what_is_s = "s"; + if (!ast_exists_extension(peer, opt_args[OPT_ARG_CALLEE_GOSUB], "s", 1, S_COR(peer->caller.id.number.valid, peer->caller.id.number.str, NULL)) && + ast_exists_extension(peer, opt_args[OPT_ARG_CALLEE_GOSUB], "~~s~~", 1, S_COR(peer->caller.id.number.valid, peer->caller.id.number.str, NULL))) { + what_is_s = "~~s~~"; + ast_copy_string(peer->exten, "~~s~~", sizeof(peer->exten)); + } + if (asprintf(&gosub_args, "%s,%s,1", opt_args[OPT_ARG_CALLEE_GOSUB], what_is_s) < 0) { ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno)); gosub_args = NULL; } Index: apps/app_queue.c =================================================================== --- apps/app_queue.c (revision 307141) +++ apps/app_queue.c (working copy) @@ -4931,13 +4931,25 @@ gosub_argstart = strchr(gosubexec, ','); if (gosub_argstart) { + const char *what_is_s = "s"; *gosub_argstart = 0; + if (!ast_exists_extension(peer, gosubexec, "s", 1, S_COR(peer->caller.id.number.valid, peer->caller.id.number.str, NULL)) && + ast_exists_extension(peer, gosubexec, "~~s~~", 1, S_COR(peer->caller.id.number.valid, peer->caller.id.number.str, NULL))) { + what_is_s = "~~s~~"; + ast_copy_string(peer->exten, "~~s~~", sizeof(peer->exten)); + } if (asprintf(&gosub_args, "%s,s,1(%s)", gosubexec, gosub_argstart + 1) < 0) { ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno)); gosub_args = NULL; } *gosub_argstart = ','; } else { + const char *what_is_s = "s"; + if (!ast_exists_extension(peer, gosubexec, "s", 1, S_COR(peer->caller.id.number.valid, peer->caller.id.number.str, NULL)) && + ast_exists_extension(peer, gosubexec, "~~s~~", 1, S_COR(peer->caller.id.number.valid, peer->caller.id.number.str, NULL))) { + what_is_s = "~~s~~"; + ast_copy_string(peer->exten, "~~s~~", sizeof(peer->exten)); + } if (asprintf(&gosub_args, "%s,s,1", gosubexec) < 0) { ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno)); gosub_args = NULL;