]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
ls.pl: check for regex correctness to avoid crashing the script
authorTomasz Konojacki <redacted>
Sun, 17 Sep 2017 04:08:24 +0000 (06:08 +0200)
committerTomasz Konojacki <redacted>
Sun, 17 Sep 2017 04:22:32 +0000 (06:22 +0200)
scripts/ls.pl

index 7af5e4e99b1a224da0bea5922d04a6080df430df..c07e94be34d0d8299084e04a97fd2b660e106781 100644 (file)
@@ -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;
        }
 }
 
git clone https://git.99rst.org/PROJECT