summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2017-01-22 18:15:08 +0545
committerGitHub <noreply@github.com>2017-01-22 18:15:08 +0545
commitf57a3d9051f904f7b915db0bc0b64849503f8647 (patch)
tree65e3cd27c185c6eef5a80d2ebde4a54555f2bac7
parentb2bb49709d6d1cb845f2c7caf40bebe375ecb2d7 (diff)
downloadpfsense-f57a3d9051f904f7b915db0bc0b64849503f8647.zip
pfsense-f57a3d9051f904f7b915db0bc0b64849503f8647.tar.gz
Interface description should be required
I was blanking out stuff to see what input error messages came about fields that are required. I was surprised that the Interface Description would save empty. The system did not immediately explode (I was playing with a bonus interface I had created in a VM) but I don't think it is desirable to have interfaces with no description. The change here also only does the other checks on the description if it has actualy been entered - no point checking a whole lot of other dependent stuff if the description is not even entered.
-rwxr-xr-xsrc/usr/local/www/interfaces.php50
1 files changed, 29 insertions, 21 deletions
diff --git a/src/usr/local/www/interfaces.php b/src/usr/local/www/interfaces.php
index 6010b95..6fe07b3 100755
--- a/src/usr/local/www/interfaces.php
+++ b/src/usr/local/www/interfaces.php
@@ -488,36 +488,44 @@ if ($_POST['apply']) {
unset($_POST['pppoe_resetdate']);
unset($_POST['pppoe_pr_preset_val']);
}
- /* description unique? */
- foreach ($ifdescrs as $ifent => $ifdescr) {
- if ($if != $ifent && $ifdescr == $_POST['descr']) {
- $input_errors[] = gettext("An interface with the specified description already exists.");
- break;
+
+ /* input validation */
+ $reqdfields = explode(" ", "descr");
+ $reqdfieldsn = array(gettext("Description"));
+ do_input_validation($_REQUEST, $reqdfields, $reqdfieldsn, $input_errors);
+
+ if (!$input_errors) {
+ /* description unique? */
+ foreach ($ifdescrs as $ifent => $ifdescr) {
+ if ($if != $ifent && $ifdescr == $_POST['descr']) {
+ $input_errors[] = gettext("An interface with the specified description already exists.");
+ break;
+ }
}
- }
- /* 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['descr']) {
- $input_errors[] = sprintf(gettext("Sorry, an alias with the name %s already exists."), $_POST['descr']);
+ /* 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['descr']) {
+ $input_errors[] = sprintf(gettext("Sorry, an alias with the name %s already exists."), $_POST['descr']);
+ }
}
}
- }
- /* Is the description already used as an interface group name? */
- if (is_array($config['ifgroups']['ifgroupentry'])) {
- foreach ($config['ifgroups']['ifgroupentry'] as $ifgroupentry) {
- if ($ifgroupentry['ifname'] == $_POST['descr']) {
- $input_errors[] = sprintf(gettext("Sorry, an interface group with the name %s already exists."), $wancfg['descr']);
+ /* Is the description already used as an interface group name? */
+ if (is_array($config['ifgroups']['ifgroupentry'])) {
+ foreach ($config['ifgroups']['ifgroupentry'] as $ifgroupentry) {
+ if ($ifgroupentry['ifname'] == $_POST['descr']) {
+ $input_errors[] = sprintf(gettext("Sorry, an interface group with the name %s already exists."), $wancfg['descr']);
+ }
}
}
- }
- if (is_numeric($_POST['descr'])) {
- $input_errors[] = gettext("The interface description cannot contain only numbers.");
+ if (is_numeric($_POST['descr'])) {
+ $input_errors[] = gettext("The interface description cannot contain only numbers.");
+ }
}
- /* input validation */
+
if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable'])) {
if (!preg_match("/^staticv4/", $_POST['type'])) {
$input_errors[] = gettext("The DHCP Server is active " .
OpenPOWER on IntegriCloud