From: Tomasz Konojacki Date: Sun, 17 Sep 2017 04:08:24 +0000 (+0200) Subject: ls.pl: check for regex correctness to avoid crashing the script X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=880e7a613e735478b59b7ad948c1a371a048f553;p=irssi-scripts.irssi.org.git ls.pl: check for regex correctness to avoid crashing the script --- diff --git a/scripts/ls.pl b/scripts/ls.pl index 7af5e4e..c07e94b 100644 --- a/scripts/ls.pl +++ b/scripts/ls.pl @@ -24,10 +24,17 @@ sub cmd_ls { my @nicks = $channel->nicks(); + my $re = eval { qr/$data/i }; + if (not $re) { + chomp $@; + $channel->print("Invalid regex pattern:\n$@"); + return; + } + foreach my $nick (@nicks) { my $n = $nick->{nick} . "!" . $nick->{host}; - $channel->print("$n") if $n =~ /$data/i; + $channel->print("$n") if $n =~ $re; } }