interfaces: make sure descriptions are properly cleansed, save description when disabled too (missed in https://github.com/opnsense/core/pull/3808) closes https://github.com/opnsense/core/issues/3942

This commit is contained in:
Ad Schellevis 2020-02-17 20:33:19 +01:00
parent 86afa90afb
commit 2a80d1a8a2
2 changed files with 3 additions and 1 deletions

View File

@ -576,6 +576,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
}
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
$pconfig = $_POST;
$input_errors = array();
if (!empty($_POST['if']) && !empty($a_interfaces[$_POST['if']])) {
$if = $_POST['if'];
@ -622,6 +623,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (isset($a_interfaces[$if]['wireless'])) {
interface_sync_wireless_clones($a_interfaces[$if], false);
}
$a_interfaces[$if]['descr'] = preg_replace('/[^a-z_0-9]/i', '', $pconfig['descr']);
write_config("Interface {$pconfig['descr']}({$if}) is now disabled.");
mark_subsystem_dirty('interfaces');

View File

@ -152,7 +152,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$newifname = 'opt' . $i;
$descr = !empty($_POST['new_entry_descr']) ? $_POST['new_entry_descr'] : 'OPT' . $i;
$config['interfaces'][$newifname] = array();
$config['interfaces'][$newifname]['descr'] = $descr;
$config['interfaces'][$newifname]['descr'] = preg_replace('/[^a-z_0-9]/i', '', $descr);;
$config['interfaces'][$newifname]['if'] = $_POST['if_add'];
$interfaces = list_interfaces();
if ($interfaces[$_POST['if_add']]['section'] == 'ppps.ppp') {