diff options
author | Phil Davis <phil.davis@inf.org> | 2017-01-22 19:37:42 +0545 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2017-01-24 10:18:54 -0200 |
commit | 99a90e92277e750a2683535151f25cc19c119004 (patch) | |
tree | 4eec96a422e35d59e04f5b6f62195dd7c802e886 /src/usr/local/www | |
parent | 400d36cc23a53cc704e6f35a84e259e39c085d9d (diff) | |
download | pfsense-99a90e92277e750a2683535151f25cc19c119004.zip pfsense-99a90e92277e750a2683535151f25cc19c119004.tar.gz |
Interface Group Name should be required
Do not allow it to be blank. Do not bother with all the other checks on the group name if it is blank.
(At the moment I can enter an Interface Group with blank name)
(cherry picked from commit 3effec3b515a97e3b5820ba8687645868b807463)
Diffstat (limited to 'src/usr/local/www')
-rw-r--r-- | src/usr/local/www/interfaces_groups_edit.php | 67 |
1 files changed, 37 insertions, 30 deletions
diff --git a/src/usr/local/www/interfaces_groups_edit.php b/src/usr/local/www/interfaces_groups_edit.php index 42f1368..cc9745a 100644 --- a/src/usr/local/www/interfaces_groups_edit.php +++ b/src/usr/local/www/interfaces_groups_edit.php @@ -91,45 +91,52 @@ if ($_POST) { unset($input_errors); $pconfig = $_POST; - if (!isset($id)) { - foreach ($a_ifgroups as $groupentry) { - if ($groupentry['ifname'] == $_POST['ifname']) { - $input_errors[] = gettext("Group name already exists!"); + /* input validation */ + $reqdfields = explode(" ", "ifname"); + $reqdfieldsn = array(gettext("Group Name")); + do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); + + if (!$input_errors) { + if (!isset($id)) { + foreach ($a_ifgroups as $groupentry) { + if ($groupentry['ifname'] == $_POST['ifname']) { + $input_errors[] = gettext("Group name already exists!"); + } } } - } - if (strlen($_POST['ifname']) > 16) { - $input_errors[] = gettext("Group name cannot have more than 16 characters."); - } + if (strlen($_POST['ifname']) > 16) { + $input_errors[] = gettext("Group name cannot have more than 16 characters."); + } - if (preg_match("/([^a-zA-Z0-9-_])+/", $_POST['ifname'])) { - $input_errors[] = gettext("Only letters (A-Z), digits (0-9), '-' and '_' are allowed as the group name."); - } + if (preg_match("/([^a-zA-Z0-9-_])+/", $_POST['ifname'])) { + $input_errors[] = gettext("Only letters (A-Z), digits (0-9), '-' and '_' are allowed as the group name."); + } - if (preg_match("/[0-9]$/", $_POST['ifname'])) { - $input_errors[] = gettext("Group name cannot end with digit."); - } + if (preg_match("/[0-9]$/", $_POST['ifname'])) { + $input_errors[] = gettext("Group name cannot end with digit."); + } - /* - * Packages (e.g. tinc) creates interface groups, reserve this - * namespace pkg- for them - */ - if (substr($_POST['ifname'], 0, 4) == 'pkg-') { - $input_errors[] = gettext("Group name cannot start with pkg-"); - } + /* + * Packages (e.g. tinc) creates interface groups, reserve this + * namespace pkg- for them + */ + if (substr($_POST['ifname'], 0, 4) == 'pkg-') { + $input_errors[] = gettext("Group name cannot start with pkg-"); + } - foreach ($interface_list_disabled as $gif => $gdescr) { - if ((strcasecmp($gdescr, $_POST['ifname']) == 0) || (strcasecmp($gif, $_POST['ifname']) == 0)) { - $input_errors[] = "The specified group name is already used by an interface. Please choose another name."; + foreach ($interface_list_disabled as $gif => $gdescr) { + if ((strcasecmp($gdescr, $_POST['ifname']) == 0) || (strcasecmp($gif, $_POST['ifname']) == 0)) { + $input_errors[] = "The specified group name is already used by an interface. Please choose another name."; + } } - } - /* Is the description already used as an alias name? */ - if (is_array($config['aliases']['alias'])) { - foreach ($config['aliases']['alias'] as $alias) { - if ($alias['name'] == $_POST['ifname']) { - $input_errors[] = gettext("An alias with this name already exists."); + /* Is the description already used as an alias name? */ + if (is_array($config['aliases']['alias'])) { + foreach ($config['aliases']['alias'] as $alias) { + if ($alias['name'] == $_POST['ifname']) { + $input_errors[] = gettext("An alias with this name already exists."); + } } } } |