From 8a590377ea2066e247b03fde5f2a205c02049956 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Sat, 22 Sep 2018 20:02:02 +1200 Subject: Admin: Don't deref scalar in /q --- Plugin/Admin.pm | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Plugin/Admin.pm b/Plugin/Admin.pm index a9a4c3c..518a076 100644 --- a/Plugin/Admin.pm +++ b/Plugin/Admin.pm @@ -106,13 +106,15 @@ sub join_channel { sub part { my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; + $where = $where->[0] if ref($where) eq "ARRAY"; + return unless is_admin($logger, $who, $ided); return "Syntax: part [channel2 ...] [partmsg]" unless - is_channel($where->[0]) or + is_channel($where) or (@arguments >= 1 and is_channel($arguments[0])); - if ((@arguments == 0 and is_channel($where->[0])) or @arguments >= 1 and not is_channel($arguments[0])) { - $rest = "$where->[0] $rest"; + if ((@arguments == 0 and is_channel($where)) or @arguments >= 1 and not is_channel($arguments[0])) { + $rest = "$where $rest"; } my $nick = (split /!/, $who)[0]; @@ -125,11 +127,13 @@ sub part { sub mode { my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; + $where = $where->[0] if ref($where) eq "ARRAY"; + return unless is_admin($logger, $who, $ided); return "Syntax: mode " unless @arguments > 0; - if (not is_channel($arguments[0] and is_channel($where->[0]))) { - $rest = "$where->[0] $rest"; + if (not is_channel($arguments[0]) and is_channel($where)) { + $rest = "$where $rest"; } $irc->yield(mode => $rest); @@ -138,13 +142,15 @@ sub mode { sub kick { my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; + $where = $where->[0] if ref($where) eq "ARRAY"; + return unless is_admin($logger, $who, $ided); return "Syntax: kick [reason]" unless @arguments >= 2 and is_channel($arguments[0]) - or @arguments >= 1 and is_channel($where->[0]); + or @arguments >= 1 and is_channel($where); - if (is_channel($where->[0]) and not is_channel($arguments[0])) { - $rest = "$where->[0] $rest"; + if (is_channel($where) and not is_channel($arguments[0])) { + $rest = "$where $rest"; } my ($channel, $kickee, undef, $reason) = $rest =~ /^(\S+)\s(\S+)((?:\s)(.*))?$/; -- cgit v1.1