From 84785529df70dbe803aa4cdf03cd9a0c9070003f Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Wed, 28 Jun 2023 08:31:41 +0200 Subject: [PATCH 1/2] Client - `leaveChannel(string)` now ensures that only valid characters are present in the provided channel's name, else throws a `BirchwoodException` --- source/birchwood/client/client.d | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/source/birchwood/client/client.d b/source/birchwood/client/client.d index 112d957..b40e36d 100644 --- a/source/birchwood/client/client.d +++ b/source/birchwood/client/client.d @@ -418,14 +418,24 @@ public class Client : Thread * * Params: * channel = the channel to leave + * Throws: + * `BirchwoodException` if the channel name + * is invalid */ public void leaveChannel(string channel) { - // TODO: Add check for valid and non-empty channel names - - /* Leave the channel */ - Message leaveMessage = new Message("", "PART", channel); - sendMessage(leaveMessage); + /* Ensure the channel name contains only valid characters */ + if(isValidText(channel)) + { + /* Leave the channel */ + Message leaveMessage = new Message("", "PART", channel); + sendMessage(leaveMessage); + } + /* If invalid characters were present */ + else + { + throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS); + } } /** From 3aa14492e23d178531c36fdd75a8f82f658ff9b4 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Wed, 28 Jun 2023 08:32:44 +0200 Subject: [PATCH 2/2] Client - Removed now-completed TODOs --- source/birchwood/client/client.d | 2 -- 1 file changed, 2 deletions(-) diff --git a/source/birchwood/client/client.d b/source/birchwood/client/client.d index b40e36d..a317369 100644 --- a/source/birchwood/client/client.d +++ b/source/birchwood/client/client.d @@ -646,13 +646,11 @@ public class Client : Thread } else { - //TODO: Invalid channel name throw new BirchwoodException(ErrorType.INVALID_CHANNEL_NAME); } } else { - //TODO: Illegal characters throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS); } }