From 3736f26a84264f3312a0cf3481b2371e4d2ab1f9 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Sat, 15 Mar 2025 09:58:46 -0700 Subject: [PATCH] Handle case where --to-destination is followed by a bare IPv6 address https://github.com/webmin/webmin/issues/2434 --- firewall/edit_rule.cgi | 6 ++++++ firewall/firewall6-lib.pl | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/firewall/edit_rule.cgi b/firewall/edit_rule.cgi index 169688fab..ce067cd07 100755 --- a/firewall/edit_rule.cgi +++ b/firewall/edit_rule.cgi @@ -141,6 +141,12 @@ if (($table->{'name'} eq 'nat' && $rule->{'chain'} ne 'POSTROUTING') && $dpfrom = $2; $dpto = $4; } + elsif (&check_ipvx_ipaddress($rule->{'to-destination'}->[1])) { + $dipfrom = $rule->{'to-destination'}->[1]; + $dipto = ""; + $dpfrom = ""; + $dpto = ""; + } } print &ui_table_row($text{'edit_dnat'}, &ui_radio("dnatdef", $dipfrom eq "" ? 1 : 0, diff --git a/firewall/firewall6-lib.pl b/firewall/firewall6-lib.pl index 6be744960..a55bb3c8d 100755 --- a/firewall/firewall6-lib.pl +++ b/firewall/firewall6-lib.pl @@ -39,7 +39,7 @@ else { "icmp6-addr-unreachable", "icmp6-port-unreachable", "echo-reply", "tcp-reset" ); -$ipvx_todestpattern='^\[([0-9A-Fa-f:]+)](\-([0-9A-Fa-f:]+))?(:(\d+)(\-(\d+))?)?$'; +$ipvx_todestpattern='^\[([0-9A-Fa-f:]+)\](\-([0-9A-Fa-f:]+))?(:(\d+)(\-(\d+))?)?$'; # set IP Version &set_ipvx_version('ipv6');