Project

General

Profile

Bug #9887 » 9887.patch

Christopher Cope, 07/07/2022 12:18 PM

View differences:

src/usr/local/pfSense/include/www/firewall_nat.inc
766 766
	init_config_arr(array('nat', 'separator'));
767 767
	$a_separators = &$config['nat']['separator'];
768 768

  
769
	$first_idx = 0;
770 769
	$num_deleted = 0;
771 770

  
772 771
	foreach ($post['rule'] as $rulei) {
......
780 779

  
781 780
		unset($a_nat[$rulei]);
782 781

  
783
		// Capture first changed filter index for later separator shifting
784
		if (!$first_idx) {
785
			$first_idx = $rulei;
782
		// Update the separators
783
		// As rules are deleted, $ridx has to be decremented or separator position will break
784
		if (count($post['rule']) == 1) { // Need special handling of single rule deletion
785
			$ridx = $rulei;
786
		} else {
787
			$ridx = $rulei - $num_deleted;
786 788
		}
787 789

  
790
		$mvnrows = -1;
791
		move_separators($a_separators, $ridx, $mvnrows);
792

  
788 793
		$num_deleted++;
789 794
	}
790 795

  
791 796
	if ($num_deleted) {
792
		move_separators($a_separators, $first_idx, -$num_deleted);
793 797
		if (write_config("NAT: Rule deleted")) {
794 798
			if ($json) {
795 799
				filter_configure();
src/usr/local/www/firewall_rules.php
199 199
		init_config_arr(array('filter', 'separator', strtolower($if)));
200 200
		$a_separators = &$config['filter']['separator'][strtolower($if)];
201 201

  
202
		$first_idx = 0;		
203 202
		$num_deleted = 0;
203

  
204 204
		foreach ($_POST['rule'] as $rulei) {
205 205
			delete_nat_association($a_filter[$rulei]['associated-rule-id']);
206 206
			unset($a_filter[$rulei]);
207 207

  
208
			// Capture first changed filter index for later separator shifting
209
			if (!$first_idx) $first_idx = ifridx($if, $rulei);
208
			// Update the separators
209
			// As rules are deleted, $ridx has to be decremented or separator position will break
210
			if (count($_POST['rule']) == 1) { // Need special handling of single rule deletion
211
				$ridx = ifridx($if, $rulei);
212
			} else {
213
				$ridx = ifridx($if, $rulei) - $num_deleted + 1;
214
			}
215

  
216
			$mvnrows = -1;
217
			move_separators($a_separators, $ridx, $mvnrows);
218

  
210 219
			$num_deleted++;
211 220
		}
212 221

  
213 222
		if ($num_deleted) {
214
			move_separators($a_separators, $first_idx, -$num_deleted);
215 223
			if (write_config(gettext("Firewall: Rules - deleted selected firewall rules."))) {
216 224
				mark_subsystem_dirty('filter');
217 225
			}
(14-14/16)