From 7bec49c4ed16d256c2baa5bfa4257ed99567df76 Mon Sep 17 00:00:00 2001 From: Ckat Date: Sat, 1 Oct 2022 16:49:15 +0000 Subject: [PATCH] Plugins/WordMorph: validate word length (#69) --- lib/PBot/Plugin/WordMorph.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/PBot/Plugin/WordMorph.pm b/lib/PBot/Plugin/WordMorph.pm index d4463c79..a7bcd600 100644 --- a/lib/PBot/Plugin/WordMorph.pm +++ b/lib/PBot/Plugin/WordMorph.pm @@ -63,7 +63,9 @@ sub wordmorph { return DB_UNAVAILABLE if not $self->{db}; - if (not exists $self->{db}->{length $args[0]}->{$args[0]}) { + if (length($args[0]) > 7) { + return "$args[0] is too long, max allowed is 7."; + } elsif (not exists $self->{db}->{length $args[0]}->{$args[0]}) { return "I do not know this word `$args[0]`."; } @@ -79,7 +81,9 @@ sub wordmorph { return DB_UNAVAILABLE if not $self->{db}; - if (not exists $self->{db}->{length $args[0]}->{$args[0]}) { + if (length($args[0]) > 7) { + return "$args[0] is too long, max allowed is 7."; + } elsif (not exists $self->{db}->{length $args[0]}->{$args[0]}) { return "I do not know this word `$args[0]`."; } else { return "Yes, `$args[0]` is a word I know.";