From 480cb6a395dabf1c836cc93a6f0acd4d282ca468 Mon Sep 17 00:00:00 2001 From: "Ahron Greenberg (agree)" <37550360+greenbea@users.noreply.github.com> Date: Tue, 12 Dec 2023 00:02:55 -0500 Subject: [PATCH] [mod_dialplan_xml] new attribute to not break from nested conditions The default behavior is to always break from proceeding to nested conditions even if a condition matches, besides when `break="never"`. Common sense says when a condition matches and `break` is set to `on-true` to proceed to nested conditions, and `break` should only apply to the subsequent conditions. This commit introduces a new extension attribute, `break-from-nested` that can be set to `false` to not break from nested conditions if the condition matches; besides, if `break="on-false"` The default behavior will be `break-from-nested=true`, so it won't break any existing systems. Example: ```xml ``` --- .../mod_dialplan_xml/mod_dialplan_xml.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c b/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c index f85a9855bb..1e651222da 100644 --- a/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c +++ b/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c @@ -573,9 +573,15 @@ static int parse_exten(switch_core_session_t *session, switch_caller_profile_t * } switch_regex_safe_free(re); - if (((anti_action == SWITCH_FALSE && do_break_i == BREAK_ON_TRUE) || - (anti_action == SWITCH_TRUE && do_break_i == BREAK_ON_FALSE)) || do_break_i == BREAK_ALWAYS) { - break; + if (switch_xml_child(xcond, "condition") && switch_xml_attr(xexten, "break-from-nested") && switch_false(switch_xml_attr(xexten, "break-from-nested"))) { + if ((anti_action == SWITCH_TRUE && do_break_i == BREAK_ON_FALSE)) { + break; + } + } else { + if (((anti_action == SWITCH_FALSE && do_break_i == BREAK_ON_TRUE) || + (anti_action == SWITCH_TRUE && do_break_i == BREAK_ON_FALSE)) || do_break_i == BREAK_ALWAYS) { + break; + } } if (proceed) { @@ -588,6 +594,12 @@ static int parse_exten(switch_core_session_t *session, switch_caller_profile_t * } } } + + /* need to recheck this if we didn't break ealier because of break-from-nested */ + if (((anti_action == SWITCH_FALSE && do_break_i == BREAK_ON_TRUE) || + (anti_action == SWITCH_TRUE && do_break_i == BREAK_ON_FALSE)) || do_break_i == BREAK_ALWAYS) { + break; + } } done: