From a5505463abb92f7728b3ab953db7c58a9cd00dee Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Fri, 8 Feb 2019 15:12:31 +0100 Subject: [PATCH] minor cleanups in firewall_nat_out_edit.php for https://github.com/opnsense/core/pull/3204 - strict page validation - disable input's when hidden (generic page issue) --- .../library/OPNsense/Firewall/SNatRule.php | 1 - src/www/firewall_nat_out_edit.php | 21 ++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/opnsense/mvc/app/library/OPNsense/Firewall/SNatRule.php b/src/opnsense/mvc/app/library/OPNsense/Firewall/SNatRule.php index d502031b7..4cf6eecc0 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Firewall/SNatRule.php +++ b/src/opnsense/mvc/app/library/OPNsense/Firewall/SNatRule.php @@ -111,7 +111,6 @@ class SNatRule extends Rule } } if (empty($rule['poolopts']) || $rule['poolopts'] != "source-hash"){ - // Make sure this is empty unless source-hash $rule['poolopts_sourcehashkey'] = ''; } if (!empty($rule['staticnatport']) || !empty($rule['nonat'])) { diff --git a/src/www/firewall_nat_out_edit.php b/src/www/firewall_nat_out_edit.php index bc2634804..a016220d9 100644 --- a/src/www/firewall_nat_out_edit.php +++ b/src/www/firewall_nat_out_edit.php @@ -196,7 +196,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { $input_errors[] = gettext("Only Round Robin pool options may be chosen when selecting an alias."); } /* Verify Source Hash Key if provided */ - if (!empty($pconfig['poolopts']) && $pconfig['poolopts'] == 'source-hash' && !empty($pconfig['poolopts_sourcehashkey'])){ + if (!empty($pconfig['poolopts_sourcehashkey'])){ + if (empty($pconfig['poolopts']) || $pconfig['poolopts'] != 'source-hash') { + $input_errors[] = gettext("Source Hash Key is only valid for Source Hash type"); + } if (substr($pconfig['poolopts_sourcehashkey'], 0, 2) != "0x" || !ctype_xdigit(substr($pconfig['poolopts_sourcehashkey'], 2, 32)) ){ $input_errors[] = gettext("Source Hash Key must be 0x followed by 32 hexadecimal digits"); } @@ -356,6 +359,7 @@ include("head.inc"); } else { $(this).removeClass("hidden"); } + $(this).prop('disabled', false); }); } else { // hide related controls @@ -365,6 +369,7 @@ include("head.inc"); } else { $(this).addClass("hidden"); } + $(this).prop('disabled', true); }); } }); @@ -749,12 +754,14 @@ include("head.inc");