]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
mod_rayo: fix error in SRGS grammar parser... <one-of><item>7</item><item>715</item...
authorChris Rienzo <chris.rienzo@grasshopper.com>
Thu, 9 Oct 2014 15:38:53 +0000 (11:38 -0400)
committerChris Rienzo <chris.rienzo@grasshopper.com>
Thu, 9 Oct 2014 15:55:45 +0000 (11:55 -0400)
src/mod/event_handlers/mod_rayo/srgs.c
src/mod/event_handlers/mod_rayo/test_srgs/main.c

index b86704828f96b52612879d49865da13944c5dd94..0f387c1e6980d902a3295e6ded5441788ab5d745 100644 (file)
@@ -1241,12 +1241,16 @@ static int is_match_end(pcre *compiled_regex, const char *input)
                        search = search_set;
                }
                search_input[input_size] = *search++;
-               result = pcre_exec(compiled_regex, NULL, search_input, input_size + 1, 0, 0,
+               result = pcre_exec(compiled_regex, NULL, search_input, input_size + 1, 0, PCRE_PARTIAL,
                        ovector, sizeof(ovector) / sizeof(ovector[0]));
                if (result > 0) {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "not match end\n");
                        return 0;
                }
+               if (result == PCRE_ERROR_PARTIAL) {
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "partial match possible - not match end\n");
+                       return 0;
+               }
        }
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "is match end\n");
        return 1;
index 2a102e89396ab045741b81df1a4890b46f379ee7..237e9edad3baa027ce7f53b9ee420cca566abcda 100644 (file)
@@ -11,8 +11,9 @@ static const char *adhearsion_menu_grammar =
        "    <one-of>\n"
        "      <item><tag>0</tag>1</item>\n"
        "      <item><tag>1</tag>5</item>\n"
-       "      <item><tag>2</tag>7</item>\n"
+       "      <item><tag>7</tag>7</item>\n"
        "      <item><tag>3</tag>9</item>\n"
+       "      <item><tag>4</tag>715</item>\n"
        "    </one-of>\n"
        "  </rule>\n"
        "</grammar>\n";
@@ -43,8 +44,10 @@ static void test_match_adhearsion_menu_grammar(void)
        ASSERT_STRING_EQUALS("1", interpretation);
        ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "6", &interpretation));
        ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "7", &interpretation));
-       ASSERT_STRING_EQUALS("2", interpretation);
+       ASSERT_EQUALS(SMT_MATCH, srgs_grammar_match(grammar, "7", &interpretation));
+       ASSERT_STRING_EQUALS("7", interpretation);
+       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "715", &interpretation));
+       ASSERT_STRING_EQUALS("4", interpretation);
        ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "8", &interpretation));
        ASSERT_NULL(interpretation);
        ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "9", &interpretation));