diff options
author | Phil Davis <phil.davis@inf.org> | 2016-11-14 00:02:40 +0545 |
---|---|---|
committer | jim-p <jimp@pfsense.org> | 2016-11-14 18:00:01 -0500 |
commit | 8100374ec15947e8f1b0f4d644b06c3a31382cf6 (patch) | |
tree | 5195832300a4f5d751c13cdbe750d32aa753e483 | |
parent | 2909468c57917a5b3bdea1901580c0b2a9b99c0d (diff) | |
download | pfsense-8100374ec15947e8f1b0f4d644b06c3a31382cf6.zip pfsense-8100374ec15947e8f1b0f4d644b06c3a31382cf6.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.php | 17 | ||||
-rw-r--r-- | src/usr/local/www/firewall_rules_edit.php | 5 |
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 9a2cc16..0100526 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 cbadfd8..92f1f53 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); |