<p>Friendly Automation <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/11276">View Change</a></p><div style="white-space:pre-wrap">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

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">pbx.c: Ignore dashes in extensions when using extenpatternmatchnew<br><br>Because hyphens are not matched literally in Asterisk dialplan, we need<br>to ignore them in our candidate extensions as well.<br><br>ASTERISK-17695 #close<br>Reported by: test011<br><br>Change-Id: I227f02301577b1633e8a55b9fe9dc149935c03f0<br>---<br>M main/pbx.c<br>1 file changed, 20 insertions(+), 5 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/pbx.c b/main/pbx.c</span><br><span>index ee5ed7e..1e5e134 100644</span><br><span>--- a/main/pbx.c</span><br><span>+++ b/main/pbx.c</span><br><span>@@ -1216,6 +1216,18 @@</span><br><span> </span><br><span> #endif</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static const char *candidate_exten_advance(const char *str)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       str++;</span><br><span style="color: hsl(120, 100%, 40%);">+        while (*str == '-') {</span><br><span style="color: hsl(120, 100%, 40%);">+         str++;</span><br><span style="color: hsl(120, 100%, 40%);">+        }</span><br><span style="color: hsl(120, 100%, 40%);">+     return str;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define MORE(s) (*candidate_exten_advance(s))</span><br><span style="color: hsl(120, 100%, 40%);">+#define ADVANCE(s) candidate_exten_advance(s)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> 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)</span><br><span> {</span><br><span>  struct match_char *p; /* note minimal stack storage requirements */</span><br><span>@@ -1231,7 +1243,7 @@</span><br><span>                  if (p->x[0] == 'N') {</span><br><span>                             if (p->x[1] == 0 && *str >= '2' && *str <= '9' ) {</span><br><span> #define  NEW_MATCHER_CHK_MATCH          \</span><br><span style="color: hsl(0, 100%, 40%);">-                                        if (p->exten && !(*(str + 1))) { /* if a shorter pattern matches along the way, might as well report it */             \</span><br><span style="color: hsl(120, 100%, 40%);">+                                   if (p->exten && !MORE(str)) { /* if a shorter pattern matches along the way, might as well report it */             \</span><br><span>                                             if (action == E_MATCH || action == E_SPAWN || action == E_FINDLABEL) { /* if in CANMATCH/MATCHMORE, don't let matches get in the way */   \</span><br><span>                                                      update_scoreboard(score, length + 1, spec + p->specificity, p->exten, 0, callerid, p->deleted, p);                 \</span><br><span>                                                        if (!p->deleted) {                                                                                           \</span><br><span>@@ -1249,10 +1261,10 @@</span><br><span>                                  }</span><br><span> </span><br><span> #define        NEW_MATCHER_RECURSE                \</span><br><span style="color: hsl(0, 100%, 40%);">-                                    if (p->next_char && (*(str + 1) || (p->next_char->x[0] == '/' && p->next_char->x[1] == 0)                 \</span><br><span style="color: hsl(120, 100%, 40%);">+                                    if (p->next_char && (MORE(str) || (p->next_char->x[0] == '/' && p->next_char->x[1] == 0)                 \</span><br><span>                                                   || p->next_char->x[0] == '!')) {                                          \</span><br><span style="color: hsl(0, 100%, 40%);">-                                                if (*(str + 1) || p->next_char->x[0] == '!') {                                                         \</span><br><span style="color: hsl(0, 100%, 40%);">-                                                  new_find_extension(str + 1, score, p->next_char, length + 1, spec + p->specificity, callerid, label, action); \</span><br><span style="color: hsl(120, 100%, 40%);">+                                         if (MORE(str) || p->next_char->x[0] == '!') {                                                         \</span><br><span style="color: hsl(120, 100%, 40%);">+                                                 new_find_extension(ADVANCE(str), score, p->next_char, length + 1, spec + p->specificity, callerid, label, action); \</span><br><span>                                                   if (score->exten)  {                                                                             \</span><br><span>                                                        ast_debug(4 ,"returning an exact match-- %s\n", score->exten->name);                         \</span><br><span>                                                               return; /* the first match is all we need */                                                 \</span><br><span>@@ -1265,7 +1277,7 @@</span><br><span>                                                               return; /* the first match is all we need */                                                 \</span><br><span>                                                       }                                                                                                                                                \</span><br><span>                                           }                                                                                                    \</span><br><span style="color: hsl(0, 100%, 40%);">-                                  } else if ((p->next_char || action == E_CANMATCH) && !*(str + 1)) {                                                                  \</span><br><span style="color: hsl(120, 100%, 40%);">+                                     } else if ((p->next_char || action == E_CANMATCH) && !MORE(str)) {                                                                  \</span><br><span>                                             score->canmatch = 1;                                                                                 \</span><br><span>                                            score->canmatch_exten = get_canmatch_exten(p);                                                       \</span><br><span>                                            if (action == E_CANMATCH || action == E_MATCHMORE) {                                                 \</span><br><span>@@ -1362,6 +1374,9 @@</span><br><span>       ast_debug(4, "return at end of func\n");</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+#undef MORE</span><br><span style="color: hsl(120, 100%, 40%);">+#undef ADVANCE</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* the algorithm for forming the extension pattern tree is also a bit simple; you</span><br><span>  * traverse all the extensions in a context, and for each char of the extension,</span><br><span>  * you see if it exists in the tree; if it doesn't, you add it at the appropriate</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/11276">change 11276</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/11276"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: I227f02301577b1633e8a55b9fe9dc149935c03f0 </div>
<div style="display:none"> Gerrit-Change-Number: 11276 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>