Add allowed API commands regex and sofia_contact

This commit is contained in:
FusionPBX 2023-10-04 12:27:45 -06:00 committed by GitHub
parent ab0f5d3295
commit 39d975a279
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 1 deletions

View File

@ -537,7 +537,24 @@
$action_array = explode(":", $destination_action, 2);
if (isset($action_array[0]) && !empty($action_array[0])) {
if ($destination->valid($action_array[0].':'.$action_array[1])) {
$dialplan["dialplan_xml"] .= " <action application=\"".xml::sanitize($action_array[0])."\" data=\"".xml::sanitize($action_array[1])."\"/>\n";
//set variables from the action array
$action_app = $action_array[0];
$action_data = $action_array[1];
//allow specific api commands
$allowed_commands = array();
$allowed_commands[] = "regex";
$allowed_commands[] = "sofia_contact";
foreach ($allowed_commands as $allowed_command) {
$action_data = str_replace('${'.$allowed_command, '#{'.$allowed_command, $action_data);
}
$action_data = xml::sanitize($action_data);
foreach ($allowed_commands as $allowed_command) {
$action_data = str_replace('#{'.$allowed_command, '${'.$allowed_command, $action_data);
}
//add the action to the dialplan xml
$dialplan["dialplan_xml"] .= " <action application=\"".xml::sanitize($action_app)."\" data=\"".$action_data."\"/>\n";
}
}
}