Use boolean setting as true boolean (#7284)

* use boolean setting as true boolean

* Update settings class to use the php filter_var function for boolean
Using the built-in filter type for boolean seems like a better option as they are faster, already hardened, and more widely tested.
I found this better method used originally by Mark J. Crane in 2022 in the content.php page so I included it here.

* Update settings class to use the php filter_var function for boolean
Using the built-in filter type for boolean seems like a better option as they are faster, already hardened, and more widely tested.
I found this better method used originally by Mark J. Crane in 2022 in the content.php page so I included it here.
This commit is contained in:
frytimo
2025-03-04 14:25:47 -04:00
committed by GitHub
parent 1b19e40be4
commit d529021b3f
99 changed files with 265 additions and 295 deletions

View File

@@ -180,9 +180,9 @@
//load editor preferences/defaults
$setting_size = !empty($_SESSION["editor"]["font_size"]["text"]) ? $_SESSION["editor"]["font_size"]["text"] : '12px';
$setting_theme = !empty($_SESSION["editor"]["theme"]["text"]) ? $_SESSION["editor"]["theme"]["text"] : 'cobalt';
$setting_invisibles = !empty($_SESSION["editor"]["invisibles"]["boolean"]) ? $_SESSION["editor"]["invisibles"]["boolean"] : 'false';
$setting_indenting = !empty($_SESSION["editor"]["indent_guides"]["boolean"]) ? $_SESSION["editor"]["indent_guides"]["boolean"] : 'false';
$setting_numbering = !empty($_SESSION["editor"]["line_numbers"]["boolean"]) ? $_SESSION["editor"]["line_numbers"]["boolean"] : 'true';
$setting_invisibles = filter_var($_SESSION["editor"]["invisibles"]["boolean"] ?? false, FILTER_VALIDATE_BOOL) ? 'true' : 'false';
$setting_indenting = filter_var($_SESSION["editor"]["indent_guides"]["boolean"] ?? false, FILTER_VALIDATE_BOOL) ? 'true' : 'false';
$setting_numbering = filter_var($_SESSION["editor"]["line_numbers"]["boolean"] ?? true, FILTER_VALIDATE_BOOL) ? 'true' : 'false';
//create token
$object = new token;

View File

@@ -40,7 +40,7 @@
$text = $language->get();
//set from session variables
$list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false';
$list_row_edit_button = filter_var($_SESSION['theme']['list_row_edit_button']['boolean'] ?? false, FILTER_VALIDATE_BOOL);
//get posted data
if (!empty($_POST['email_templates'])) {
@@ -249,7 +249,7 @@
echo th_order_by('template_type', $text['label-template_type'], $order_by, $order, null, null, $param);
echo th_order_by('template_enabled', $text['label-template_enabled'], $order_by, $order, null, "class='center pct-10'", $param);
echo th_order_by('template_description', $text['label-template_description'], $order_by, $order, null, "class='hide-sm-dn'", $param);
if (permission_exists('email_template_edit') && $list_row_edit_button == 'true') {
if (permission_exists('email_template_edit') && $list_row_edit_button) {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
@@ -303,7 +303,7 @@
}
echo " </td>\n";
echo " <td class='description overflow hide-sm-dn'>".escape($row['template_description'])."</td>\n";
if (permission_exists('email_template_edit') && $list_row_edit_button == 'true') {
if (permission_exists('email_template_edit') && $list_row_edit_button) {
echo " <td class='action-button'>";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";