summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2016-11-14 00:02:40 +0545
committerjim-p <jimp@pfsense.org>2016-11-14 18:00:05 -0500
commitbf2c7206a4dc7aa1acf2190affb675a51e02a32e (patch)
tree23325799ae89fb3a9bb13725d498ce0f0ddbeddc
parent09cc19c2798a779791ca0976ba4d281723fc0d3c (diff)
downloadpfsense-bf2c7206a4dc7aa1acf2190affb675a51e02a32e.zip
pfsense-bf2c7206a4dc7aa1acf2190affb675a51e02a32e.tar.gz
Fix #6918 Allow aliases with capital letters in rules
Expand the types of Form_IpAddress so that the caller can specify exactly what combination of IPv4, IPv6 address and alias is allowed for the field. Set the appropriate input pattern and hover help text. Only toLowercase() the entered value if it has a ":" in it - i.e. it looks like it is intended to be an IPv6 address (rather than an IPv4 or an alias name).
-rw-r--r--src/usr/local/www/classes/Form/IpAddress.class.php17
-rw-r--r--src/usr/local/www/firewall_rules_edit.php5
2 files changed, 20 insertions, 2 deletions
diff --git a/src/usr/local/www/classes/Form/IpAddress.class.php b/src/usr/local/www/classes/Form/IpAddress.class.php
index b339670..0cdae29 100644
--- a/src/usr/local/www/classes/Form/IpAddress.class.php
+++ b/src/usr/local/www/classes/Form/IpAddress.class.php
@@ -77,6 +77,23 @@ class Form_IpAddress extends Form_Input
$this->_attributes['title'] = 'An IPv6 address like 1:2a:3b:ffff::1';
$this->_attributes['onChange'] = 'javascript:this.value=this.value.toLowerCase();';
break;
+
+ case "ALIASV4V6":
+ $this->_attributes['pattern'] = '[a-zA-Z0-9_.:]+';
+ $this->_attributes['title'] = 'An IPv4 address like 1.2.3.4 or an IPv6 address like 1:2a:3b:ffff::1 or an alias';
+ $this->_attributes['onChange'] = 'javascript:if (this.value.indexOf(":") > -1) {this.value=this.value.toLowerCase();}';
+ break;
+
+ case "ALIASV4":
+ $this->_attributes['pattern'] = '[a-zA-Z0-9_.:]+';
+ $this->_attributes['title'] = 'An IPv4 address like 1.2.3.4 or an alias';
+ break;
+
+ case "ALIASV6":
+ $this->_attributes['pattern'] = '[a-zA-Z0-9_.:]+';
+ $this->_attributes['title'] = 'An IPv6 address like 1:2a:3b:ffff::1 or an alias';
+ $this->_attributes['onChange'] = 'javascript:if (this.value.indexOf(":") > -1) {this.value=this.value.toLowerCase();}';
+ break;
}
}
diff --git a/src/usr/local/www/firewall_rules_edit.php b/src/usr/local/www/firewall_rules_edit.php
index 7a4862e..d3fc654 100644
--- a/src/usr/local/www/firewall_rules_edit.php
+++ b/src/usr/local/www/firewall_rules_edit.php
@@ -1354,8 +1354,9 @@ foreach (['src' => 'Source', 'dst' => 'Destination'] as $type => $name) {
$group->add(new Form_IpAddress(
$type,
$name .' Address',
- $pconfig[$type]
- ))->addMask($type .'mask', $pconfig[$type.'mask'])->setPattern('[a-zA-Z0-9_.:]+');
+ $pconfig[$type],
+ 'ALIASV4V6'
+ ))->addMask($type .'mask', $pconfig[$type.'mask']);
$section->add($group);
OpenPOWER on IntegriCloud