mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-06-07 13:35:00 +00:00
mod_rayo: fix error in SRGS grammar parser... <one-of><item>7</item><item>715</item></one-of> will return MATCH_END with input of 7 instead of MATCH since 715 is a potential match with further input.
This commit is contained in:
parent
63734bcde0
commit
28bc992fce
@ -1256,12 +1256,16 @@ static int is_match_end(pcre *compiled_regex, const char *input)
|
|||||||
search = search_set;
|
search = search_set;
|
||||||
}
|
}
|
||||||
search_input[input_size] = *search++;
|
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]));
|
ovector, sizeof(ovector) / sizeof(ovector[0]));
|
||||||
if (result > 0) {
|
if (result > 0) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "not match end\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "not match end\n");
|
||||||
return 0;
|
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");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "is match end\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -11,8 +11,9 @@ static const char *adhearsion_menu_grammar =
|
|||||||
" <one-of>\n"
|
" <one-of>\n"
|
||||||
" <item><tag>0</tag>1</item>\n"
|
" <item><tag>0</tag>1</item>\n"
|
||||||
" <item><tag>1</tag>5</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>3</tag>9</item>\n"
|
||||||
|
" <item><tag>4</tag>715</item>\n"
|
||||||
" </one-of>\n"
|
" </one-of>\n"
|
||||||
" </rule>\n"
|
" </rule>\n"
|
||||||
"</grammar>\n";
|
"</grammar>\n";
|
||||||
@ -43,8 +44,10 @@ static void test_match_adhearsion_menu_grammar(void)
|
|||||||
ASSERT_STRING_EQUALS("1", interpretation);
|
ASSERT_STRING_EQUALS("1", interpretation);
|
||||||
ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "6", &interpretation));
|
ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "6", &interpretation));
|
||||||
ASSERT_NULL(interpretation);
|
ASSERT_NULL(interpretation);
|
||||||
ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "7", &interpretation));
|
ASSERT_EQUALS(SMT_MATCH, srgs_grammar_match(grammar, "7", &interpretation));
|
||||||
ASSERT_STRING_EQUALS("2", 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_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "8", &interpretation));
|
||||||
ASSERT_NULL(interpretation);
|
ASSERT_NULL(interpretation);
|
||||||
ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "9", &interpretation));
|
ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "9", &interpretation));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user