[Asterisk-code-review] pbx.c: Ignore dashes in extensions when using extenpatternmatchnew (...asterisk[13])
Friendly Automation
asteriskteam at digium.com
Tue Apr 16 12:09:25 CDT 2019
Friendly Automation has submitted this change and it was merged. ( https://gerrit.asterisk.org/c/asterisk/+/11275 )
Change subject: pbx.c: Ignore dashes in extensions when using extenpatternmatchnew
......................................................................
pbx.c: Ignore dashes in extensions when using extenpatternmatchnew
Because hyphens are not matched literally in Asterisk dialplan, we need
to ignore them in our candidate extensions as well.
ASTERISK-17695 #close
Reported by: test011
Change-Id: I227f02301577b1633e8a55b9fe9dc149935c03f0
---
M main/pbx.c
1 file changed, 20 insertions(+), 5 deletions(-)
Approvals:
Benjamin Keith Ford: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Friendly Automation: Approved for Submit
diff --git a/main/pbx.c b/main/pbx.c
index b4a5448..514c294 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -1183,6 +1183,18 @@
#endif
+static const char *candidate_exten_advance(const char *str)
+{
+ str++;
+ while (*str == '-') {
+ str++;
+ }
+ return str;
+}
+
+#define MORE(s) (*candidate_exten_advance(s))
+#define ADVANCE(s) candidate_exten_advance(s)
+
static void new_find_extension(const char *str, struct scoreboard *score, struct match_char *tree, int length, int spec, const char *callerid, const char *label, enum ext_match_t action)
{
struct match_char *p; /* note minimal stack storage requirements */
@@ -1198,7 +1210,7 @@
if (p->x[0] == 'N') {
if (p->x[1] == 0 && *str >= '2' && *str <= '9' ) {
#define NEW_MATCHER_CHK_MATCH \
- if (p->exten && !(*(str + 1))) { /* if a shorter pattern matches along the way, might as well report it */ \
+ if (p->exten && !MORE(str)) { /* if a shorter pattern matches along the way, might as well report it */ \
if (action == E_MATCH || action == E_SPAWN || action == E_FINDLABEL) { /* if in CANMATCH/MATCHMORE, don't let matches get in the way */ \
update_scoreboard(score, length + 1, spec + p->specificity, p->exten, 0, callerid, p->deleted, p); \
if (!p->deleted) { \
@@ -1216,10 +1228,10 @@
}
#define NEW_MATCHER_RECURSE \
- if (p->next_char && (*(str + 1) || (p->next_char->x[0] == '/' && p->next_char->x[1] == 0) \
+ if (p->next_char && (MORE(str) || (p->next_char->x[0] == '/' && p->next_char->x[1] == 0) \
|| p->next_char->x[0] == '!')) { \
- if (*(str + 1) || p->next_char->x[0] == '!') { \
- new_find_extension(str + 1, score, p->next_char, length + 1, spec + p->specificity, callerid, label, action); \
+ if (MORE(str) || p->next_char->x[0] == '!') { \
+ new_find_extension(ADVANCE(str), score, p->next_char, length + 1, spec + p->specificity, callerid, label, action); \
if (score->exten) { \
ast_debug(4 ,"returning an exact match-- %s\n", score->exten->name); \
return; /* the first match is all we need */ \
@@ -1232,7 +1244,7 @@
return; /* the first match is all we need */ \
} \
} \
- } else if ((p->next_char || action == E_CANMATCH) && !*(str + 1)) { \
+ } else if ((p->next_char || action == E_CANMATCH) && !MORE(str)) { \
score->canmatch = 1; \
score->canmatch_exten = get_canmatch_exten(p); \
if (action == E_CANMATCH || action == E_MATCHMORE) { \
@@ -1329,6 +1341,9 @@
ast_debug(4, "return at end of func\n");
}
+#undef MORE
+#undef ADVANCE
+
/* the algorithm for forming the extension pattern tree is also a bit simple; you
* traverse all the extensions in a context, and for each char of the extension,
* you see if it exists in the tree; if it doesn't, you add it at the appropriate
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/11275
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Change-Id: I227f02301577b1633e8a55b9fe9dc149935c03f0
Gerrit-Change-Number: 11275
Gerrit-PatchSet: 3
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Sean Bright <sean.bright at gmail.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190416/2769af17/attachment.html>
More information about the asterisk-code-review
mailing list