fix: enforce message checking

* follow-up of 33e268d7dc
* fixes #1
This commit is contained in:
citizen-VM 2020-08-24 18:34:22 +02:00
parent cff1ab498e
commit 27a73f94eb
Signed by: wanderer
GPG Key ID: 6391444A736EEE7E

View File

@ -168,27 +168,27 @@ namespace KRY_0x01_ng
return; return;
} }
void check_cryptmessage(TextBox tb_m) bool check_cryptmessage(TextBox tb_m)
{ {
if (tb_m.Text.Length == 0) if (tb_m.Text.Length == 0)
{ {
MessageBox.Show("Empty message, nothing to do.", "Warning"); MessageBox.Show("Empty message, nothing to do.", "Warning");
return; return false;
} }
string msg = tb_m.Text.ToUpper(); string msg = tb_m.Text.ToUpper();
Match match = Regex.Match(msg, @"\d|\s+|W"); Match match = Regex.Match(msg, @"\d|\s+|W");
if (match.Success) 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"); 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) 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"); 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; textBox9.Text = msg;
return; return true;
} }
string msg_hack_up(string msg) string msg_hack_up(string msg)
@ -297,7 +297,10 @@ namespace KRY_0x01_ng
return; return;
} }
fill_array_table(); fill_array_table();
check_cryptmessage(textBox9); if (!check_cryptmessage(textBox9))
{
return;
}
string message = ""; string message = "";
string crm = textBox9.Text; string crm = textBox9.Text;