From bdaa5235d4c3f4e226e4e7ebee55fc7ff5fd4360 Mon Sep 17 00:00:00 2001 From: Renato Botelho do Couto Date: Wed, 11 Sep 2019 10:31:55 -0300 Subject: [PATCH] Fix #6195: Allow to change NAT Outbound mode make_config_revision_entry() second parameter expects a username to override current logged in user in special cases. It's used when a tool (e.g. wizard) is used to configure some functionality. As it was already noted in easyrule.inc, this parameter cannot have international characters since the tag where it's stored in config.xml doesn't use CDATA. Remove gettext() calls and add a comment on each place make_config_revision_entry() is called with username parameter --- src/etc/phpshellsessions/enableallowallwan | 4 ++ src/usr/local/www/firewall_nat_edit.php | 7 ++- src/usr/local/www/firewall_nat_out.php | 7 ++- src/usr/local/www/wizards/openvpn_wizard.inc | 12 +++- .../traffic_shaper_wizard_dedicated.inc | 45 +++++++++++--- .../traffic_shaper_wizard_multi_all.inc | 58 ++++++++++++++++--- 6 files changed, 114 insertions(+), 19 deletions(-) diff --git a/src/etc/phpshellsessions/enableallowallwan b/src/etc/phpshellsessions/enableallowallwan index 70ccd2fbe5..669dc3781b 100644 --- a/src/etc/phpshellsessions/enableallowallwan +++ b/src/etc/phpshellsessions/enableallowallwan @@ -35,6 +35,10 @@ $config["filter"]["rule"][] = array( "source" => array("any" => ""), "destination" => array("any" => ""), "descr" => "Allow all ipv4+ipv6 via pfSsh.php", + /* + * Do not translate this, it's considered a username which cannot + * contain international characters + */ "created" => make_config_revision_entry(null, "pfSsh.php added allow all wan rule") ); diff --git a/src/usr/local/www/firewall_nat_edit.php b/src/usr/local/www/firewall_nat_edit.php index 6ac9f1543f..b7d80d54bd 100644 --- a/src/usr/local/www/firewall_nat_edit.php +++ b/src/usr/local/www/firewall_nat_edit.php @@ -482,7 +482,12 @@ if ($_POST['save']) { if ($_POST['filter-rule-association'] == 'add-associated') { $filterent['associated-rule-id'] = $natent['associated-rule-id'] = get_unique_id(); $filterent['tracker'] = (int)microtime(true); - $filterent['created'] = make_config_revision_entry(null, gettext("NAT Port Forward")); + /* + * Do not translate this, it's considered a + * username which cannot contain international + * characters + */ + $filterent['created'] = make_config_revision_entry(null, "NAT Port Forward"); $config['filter']['rule'][] = $filterent; } diff --git a/src/usr/local/www/firewall_nat_out.php b/src/usr/local/www/firewall_nat_out.php index 0813678f30..3845ad5719 100644 --- a/src/usr/local/www/firewall_nat_out.php +++ b/src/usr/local/www/firewall_nat_out.php @@ -108,7 +108,12 @@ if ($_POST['save']) { $natent['descr'] .= sprintf(gettext(' - %1$s to %2$s'), $tonathost['descr'], convert_real_interface_to_friendly_descr($natent['interface'])); - $natent['created'] = make_config_revision_entry(null, gettext("Manual Outbound NAT Switch")); + /* + * Do not translate this, it's considered a + * username which cannot contain international + * characters + */ + $natent['created'] = make_config_revision_entry(null, "Manual Outbound NAT Switch"); /* Try to detect already auto created rules and avoid duplicating them */ $found = false; diff --git a/src/usr/local/www/wizards/openvpn_wizard.inc b/src/usr/local/www/wizards/openvpn_wizard.inc index 8274a48316..e8187275d2 100644 --- a/src/usr/local/www/wizards/openvpn_wizard.inc +++ b/src/usr/local/www/wizards/openvpn_wizard.inc @@ -673,7 +673,11 @@ function step12_submitphpaction() { $rule['type'] = "pass"; $rule['enabled'] = "on"; $rule['tracker'] = $tracker++; - $rule['created'] = make_config_revision_entry(null, gettext("OpenVPN Wizard")); + /* + * Do not translate this, it's considered a username which + * cannot contain international characters + */ + $rule['created'] = make_config_revision_entry(null, "OpenVPN Wizard"); $config['filter']['rule'][] = $rule; } @@ -690,7 +694,11 @@ function step12_submitphpaction() { $rule['type'] = "pass"; $rule['enabled'] = "on"; $rule['tracker'] = $tracker++; - $rule['created'] = make_config_revision_entry(null, gettext("OpenVPN Wizard")); + /* + * Do not translate this, it's considered a username which + * cannot contain international characters + */ + $rule['created'] = make_config_revision_entry(null, "OpenVPN Wizard"); $config['filter']['rule'][] = $rule; } diff --git a/src/usr/local/www/wizards/traffic_shaper_wizard_dedicated.inc b/src/usr/local/www/wizards/traffic_shaper_wizard_dedicated.inc index 509a222ca8..6a5c182327 100644 --- a/src/usr/local/www/wizards/traffic_shaper_wizard_dedicated.inc +++ b/src/usr/local/www/wizards/traffic_shaper_wizard_dedicated.inc @@ -1493,7 +1493,11 @@ function apply_all_chosen_items() { $rule['floating'] = "yes"; $rule['wizard'] = "yes"; $rule['enabled'] = "on"; - $rule['created'] = make_config_revision_entry(null, gettext("Traffic Shaper Wizard")); + /* + * Do not translate this, it's considered a username + * which cannot contain international characters + */ + $rule['created'] = make_config_revision_entry(null, "Traffic Shaper Wizard"); $rule['tracker'] = $tracker++; $config['filter']['rule'][] = $rule; } @@ -1514,7 +1518,11 @@ function apply_all_chosen_items() { $rule['floating'] = "yes"; $rule['wizard'] = "yes"; $rule['enabled'] = "on"; - $rule['created'] = make_config_revision_entry(null, gettext("Traffic Shaper Wizard")); + /* + * Do not translate this, it's considered a username + * which cannot contain international characters + */ + $rule['created'] = make_config_revision_entry(null, "Traffic Shaper Wizard"); $rule['tracker'] = $tracker++; $config['filter']['rule'][] = $rule; @@ -1529,7 +1537,11 @@ function apply_all_chosen_items() { $rule['floating'] = "yes"; $rule['wizard'] = "yes"; $rule['enabled'] = "on"; - $rule['created'] = make_config_revision_entry(null, gettext("Traffic Shaper Wizard")); + /* + * Do not translate this, it's considered a username + * which cannot contain international characters + */ + $rule['created'] = make_config_revision_entry(null, "Traffic Shaper Wizard"); $rule['tracker'] = $tracker++; $config['filter']['rule'][] = $rule; @@ -1547,7 +1559,11 @@ function apply_all_chosen_items() { $rule['floating'] = "yes"; $rule['wizard'] = "yes"; $rule['enabled'] = "on"; - $rule['created'] = make_config_revision_entry(null, gettext("Traffic Shaper Wizard")); + /* + * Do not translate this, it's considered a username + * which cannot contain international characters + */ + $rule['created'] = make_config_revision_entry(null, "Traffic Shaper Wizard"); $rule['tracker'] = $tracker++; $config['filter']['rule'][] = $rule; @@ -1567,7 +1583,12 @@ function apply_all_chosen_items() { $rule['destination']['port'] = $voip[2]."-".$voip[3]; if ($voip[1] != '') $rule['protocol'] = $voip[1]; - $rule['created'] = make_config_revision_entry(null, gettext("Traffic Shaper Wizard")); + /* + * Do not translate this, it's considered a + * username which cannot contain international + * characters + */ + $rule['created'] = make_config_revision_entry(null, "Traffic Shaper Wizard"); $rule['tracker'] = $tracker++; $config['filter']['rule'][] = $rule; } @@ -1592,7 +1613,12 @@ function apply_all_chosen_items() { $rule['destination']['port'] = $p2pclient[2]."-".$p2pclient[3]; if ($p2pclient[1] != '') $rule['protocol'] = $p2pclient[1]; - $rule['created'] = make_config_revision_entry(null, gettext("Traffic Shaper Wizard")); + /* + * Do not translate this, it's considered a + * username which cannot contain international + * characters + */ + $rule['created'] = make_config_revision_entry(null, "Traffic Shaper Wizard"); $rule['tracker'] = $tracker++; $config['filter']['rule'][] = $rule; } @@ -1672,7 +1698,12 @@ function apply_all_chosen_items() { } if ($otherclient[1] != '') $rule['protocol'] = $otherclient[1]; - $rule['created'] = make_config_revision_entry(null, gettext("Traffic Shaper Wizard")); + /* + * Do not translate this, it's + * considered a username which cannot + * contain international characters + */ + $rule['created'] = make_config_revision_entry(null, "Traffic Shaper Wizard"); $rule['tracker'] = $tracker++; $config['filter']['rule'][] = $rule; } diff --git a/src/usr/local/www/wizards/traffic_shaper_wizard_multi_all.inc b/src/usr/local/www/wizards/traffic_shaper_wizard_multi_all.inc index 3ad867dae5..4e5a3139fb 100644 --- a/src/usr/local/www/wizards/traffic_shaper_wizard_multi_all.inc +++ b/src/usr/local/www/wizards/traffic_shaper_wizard_multi_all.inc @@ -1579,7 +1579,11 @@ function apply_all_chosen_items() { $rule['floating'] = "yes"; $rule['wizard'] = "yes"; $rule['enabled'] = "on"; - $rule['created'] = make_config_revision_entry(null, gettext("Traffic Shaper Wizard")); + /* + * Do not translate this, it's considered a username + * which cannot contain international characters + */ + $rule['created'] = make_config_revision_entry(null, "Traffic Shaper Wizard"); $rule['tracker'] = $tracker++; $config['filter']['rule'][] = $rule; @@ -1601,7 +1605,12 @@ function apply_all_chosen_items() { $rule['floating'] = "yes"; $rule['wizard'] = "yes"; $rule['enabled'] = "on"; - $rule['created'] = make_config_revision_entry(null, gettext("Traffic Shaper Wizard")); + /* + * Do not translate this, it's + * considered a username which cannot + * contain international characters + */ + $rule['created'] = make_config_revision_entry(null, "Traffic Shaper Wizard"); $rule['tracker'] = $tracker++; $config['filter']['rule'][] = $rule; @@ -1616,7 +1625,12 @@ function apply_all_chosen_items() { $rule['floating'] = "yes"; $rule['wizard'] = "yes"; $rule['enabled'] = "on"; - $rule['created'] = make_config_revision_entry(null, gettext("Traffic Shaper Wizard")); + /* + * Do not translate this, it's + * considered a username which cannot + * contain international characters + */ + $rule['created'] = make_config_revision_entry(null, "Traffic Shaper Wizard"); $rule['tracker'] = $tracker++; $config['filter']['rule'][] = $rule; @@ -1634,7 +1648,12 @@ function apply_all_chosen_items() { $rule['floating'] = "yes"; $rule['wizard'] = "yes"; $rule['enabled'] = "on"; - $rule['created'] = make_config_revision_entry(null, gettext("Traffic Shaper Wizard")); + /* + * Do not translate this, it's + * considered a username which cannot + * contain international characters + */ + $rule['created'] = make_config_revision_entry(null, "Traffic Shaper Wizard"); $rule['tracker'] = $tracker++; $config['filter']['rule'][] = $rule; @@ -1654,7 +1673,13 @@ function apply_all_chosen_items() { $rule['destination']['port'] = $voip[2]."-".$voip[3]; if ($voip[1] != '') $rule['protocol'] = $voip[1]; - $rule['created'] = make_config_revision_entry(null, gettext("Traffic Shaper Wizard")); + /* + * Do not translate this, it's + * considered a username which + * cannot contain international + * characters + */ + $rule['created'] = make_config_revision_entry(null, "Traffic Shaper Wizard"); $rule['tracker'] = $tracker++; $config['filter']['rule'][] = $rule; } @@ -1679,7 +1704,13 @@ function apply_all_chosen_items() { $rule['destination']['port'] = $p2pclient[2]."-".$p2pclient[3]; if ($p2pclient[1] != '') $rule['protocol'] = $p2pclient[1]; - $rule['created'] = make_config_revision_entry(null, gettext("Traffic Shaper Wizard")); + /* + * Do not translate this, it's + * considered a username which + * cannot contain international + * characters + */ + $rule['created'] = make_config_revision_entry(null, "Traffic Shaper Wizard"); $rule['tracker'] = $tracker++; $config['filter']['rule'][] = $rule; } @@ -1707,7 +1738,13 @@ function apply_all_chosen_items() { $rule['destination']['port'] = $Gameclient[2]."-".$Gameclient[3]; if ($Gameclient[1] != '') $rule['protocol'] = $Gameclient[1]; - $rule['created'] = make_config_revision_entry(null, gettext("Traffic Shaper Wizard")); + /* + * Do not translate this, it's + * considered a username which + * cannot contain international + * characters + */ + $rule['created'] = make_config_revision_entry(null, "Traffic Shaper Wizard"); $rule['tracker'] = $tracker++; $config['filter']['rule'][] = $rule; } @@ -1761,7 +1798,12 @@ function apply_all_chosen_items() { } if ($otherclient[1] != '') $rule['protocol'] = $otherclient[1]; - $rule['created'] = make_config_revision_entry(null, gettext("Traffic Shaper Wizard")); + /* + * Do not translate this, it's + * considered a username which cannot + * contain international characters + */ + $rule['created'] = make_config_revision_entry(null, "Traffic Shaper Wizard"); $rule['tracker'] = $tracker++; $config['filter']['rule'][] = $rule; }