From 85f5824f7bb031cbafc623ba56538804d86833fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20S=C3=BC=C3=9Fenguth?= Date: Wed, 13 Apr 2022 13:49:22 +0200 Subject: [PATCH] Added more descriptive error messages for three cases. --- edit_list.php | 5 +++-- misc/smarty/templates_en/error.tpl | 6 ++++++ save_list.php | 5 +++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/edit_list.php b/edit_list.php index 1d616aa..1211d51 100644 --- a/edit_list.php +++ b/edit_list.php @@ -13,16 +13,16 @@ if (!isset($_SESSION["auth"]) || $_SESSION["auth"] != 1) exit(); } -// We do not print any error in the next three cases, because a legitimate -// user will never produce such results, even with disabled javascript if ( preg_match("/[^a-z0-9_-]/", $list_name) ) { + $_SESSION["error_code"] = 14; header("Location: error.php"); exit(); } if ( strlen($list_name) > 50 ) { + $_SESSION["error_code"] = 13; header("Location: error.php"); exit(); } @@ -30,6 +30,7 @@ if ( strlen($list_name) > 50 ) // Test list existence if( !is_dir("$lists_path/$domain/$list_name") || $list_name == "" ) { + $_SESSION["error_code"] = 12; header("Location: error.php"); exit(); } diff --git a/misc/smarty/templates_en/error.tpl b/misc/smarty/templates_en/error.tpl index 3998f8b..607180a 100644 --- a/misc/smarty/templates_en/error.tpl +++ b/misc/smarty/templates_en/error.tpl @@ -36,6 +36,12 @@ There is an incorrect email in the moderators list. {elseif $error_code == 11} You do not own this list. + {elseif $error_code == 12} + The list does not exist within the mlmmj working folder. + {elseif $error_code == 13} + The list name exceeds the maximum length of 50 chars. + {elseif $error_code == 14} + The list name contains chars which are not allowed. {else} Unknown error. {/if} diff --git a/save_list.php b/save_list.php index 8773fc9..20be042 100644 --- a/save_list.php +++ b/save_list.php @@ -32,16 +32,16 @@ if ( !isset($_SESSION["auth"]) || $_SESSION["auth"] != 1 ) $domain = $_SESSION["domain"]; -// We do not print any error in the next four cases, because a legitimate -// user will never produce such results, even with disabled javascript if ( preg_match("/[^a-z0-9_-]/", $list_name) ) { + $_SESSION["error_code"] = 14; header("Location: error.php"); exit(); } if ( strlen($list_name) > 50 ) { + $_SESSION["error_code"] = 13; header("Location: error.php"); exit(); } @@ -49,6 +49,7 @@ if ( strlen($list_name) > 50 ) // Test list existence if( !is_dir("$lists_path/$domain/$list_name") || $list_name == "" ) { + $_SESSION["error_code"] = 12; header("Location: error.php"); exit(); }