From 27a73f94ebfb349b9268fa190ca9d32dd90dfa75 Mon Sep 17 00:00:00 2001 From: citizen-VM Date: Mon, 24 Aug 2020 18:34:22 +0200 Subject: [PATCH] fix: enforce message checking * follow-up of 33e268d7dc * fixes #1 --- main_form.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/main_form.cs b/main_form.cs index d7fcafd..a3e7365 100644 --- a/main_form.cs +++ b/main_form.cs @@ -168,27 +168,27 @@ namespace KRY_0x01_ng return; } - void check_cryptmessage(TextBox tb_m) + bool check_cryptmessage(TextBox tb_m) { if (tb_m.Text.Length == 0) { MessageBox.Show("Empty message, nothing to do.", "Warning"); - return; + return false; } string msg = tb_m.Text.ToUpper(); Match match = Regex.Match(msg, @"\d|\s+|W"); if (match.Success) { MessageBox.Show("Only alphabetic characters (with the exception of W) are allowed.\nCheck the cryptmessage for numbers, symbols or tab whitespace and remove them before continuing.", "Error"); - return; + return false; } if (tb_m.Text.Length % 2 != 0) { MessageBox.Show("This pretty sure can't be a message I can deal with (uneven number of characters).", "Error"); - return; + return false; } textBox9.Text = msg; - return; + return true; } string msg_hack_up(string msg) @@ -297,7 +297,10 @@ namespace KRY_0x01_ng return; } fill_array_table(); - check_cryptmessage(textBox9); + if (!check_cryptmessage(textBox9)) + { + return; + } string message = ""; string crm = textBox9.Text;