diff --git a/INDEV b/INDEV index 8d1192a8..846d1ca5 100644 --- a/INDEV +++ b/INDEV @@ -3177,3 +3177,7 @@ CHANGES: 98. fixed incorrect CASEMAPPING in RPL_ISUPPORT. thx @GLolol. renamed repository to "juno." + + 99. fixed #74 where the forward channel could be the same as the original one. + removed old, unsued 'do_not_set' mode block options. + added some extra santity checks to Forward module. diff --git a/VERSION b/VERSION index c12c3a1d..08c1de4f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -10.98 +10.99 diff --git a/modules/Channel/Forward.module/Forward.json b/modules/Channel/Forward.module/Forward.json index 38ab39fa..29c9b159 100644 --- a/modules/Channel/Forward.module/Forward.json +++ b/modules/Channel/Forward.module/Forward.json @@ -13,5 +13,5 @@ "description" : "adds channel forwarding abilities", "name" : "Channel::Forward", "package" : "M::Channel::Forward", - "version" : "1.9" + "version" : "2" } diff --git a/modules/Channel/Forward.module/Forward.pm b/modules/Channel/Forward.module/Forward.pm index 96267e40..6b26740d 100644 --- a/modules/Channel/Forward.module/Forward.pm +++ b/modules/Channel/Forward.module/Forward.pm @@ -80,7 +80,6 @@ sub cmode_forward { # no length, don't set if (!length $mode->{param}) { - $mode->{do_not_set} = 1; return; } @@ -89,8 +88,19 @@ sub cmode_forward { # to be forwarded to can forward. my $f_channel = $pool->lookup_channel($mode->{param}); my $source = $mode->{source}; - $source->numeric(ERR_NOSUCHCHANNEL => $mode->{param}) and return - if (!$f_channel && $source->isa('user')); + + # channel does not exist. + if (!$f_channel) { + $source->numeric(ERR_NOSUCHCHANNEL => $mode->{param}) + if $source->isa('user'); + return; + } + + # forwarding to the same channel. + if ($f_channel == $channel) { + # TODO: add a numeric? + return; + } # is the channel free forward or is the user opped? if (!$source->isa('user') || $f_channel->is_mode('free_forward') @@ -119,7 +129,12 @@ sub on_user_join_failed { return unless $channel->is_mode('forward'); my $f_ch_name = $channel->mode_parameter('forward'); - # FIXME: wouldn't hurt to double-check that the channel name is valid here + # this was already checked once, but this is just in case it was + # set by a pseudoserver or something and is invalid. + if (!utils::validchan($f_ch_name)) { + L("Invalid forward channel name for $$channel{name}: $f_ch_name"); + return; + } # We need the channel object, unfortunately it is not always the case that # we are being forwarded to a channel that already exists. diff --git a/modules/Channel/Key.module/Key.json b/modules/Channel/Key.module/Key.json index ced7dba0..2f0714d1 100644 --- a/modules/Channel/Key.module/Key.json +++ b/modules/Channel/Key.module/Key.json @@ -1,5 +1,8 @@ { - "version" : "1.7", + "author" : { + "name" : "Matthew Barksdale", + "website" : "https://github.com/mattwb65" + }, "depends" : { "modules" : [ "Base::ChannelModes", @@ -8,9 +11,6 @@ }, "description" : "adds channel key mode", "name" : "Channel::Key", - "author" : { - "website" : "https://github.com/mattwb65", - "name" : "Matthew Barksdale" - }, - "package" : "M::Channel::Key" + "package" : "M::Channel::Key", + "version" : "1.8" } diff --git a/modules/Channel/Key.module/Key.pm b/modules/Channel/Key.module/Key.pm index 972cefcb..2c881fb9 100644 --- a/modules/Channel/Key.module/Key.pm +++ b/modules/Channel/Key.module/Key.pm @@ -24,13 +24,13 @@ use utils qw(cut_to_limit cols); our ($api, $mod, $pool); sub init { - + # register key mode block. $mod->register_channel_mode_block( name => 'key', code => \&cmode_key ) or return; - + # register ERR_BADCHANNELKEY $mod->register_user_numeric( name => shift @$_, @@ -40,44 +40,43 @@ sub init { [ ERR_BADCHANNELKEY => 481, '%s :Invalid channel key' ], [ ERR_KEYSET => 467, '%s :Channel key already set' ] ); - + # Hook on the can_join event to prevent joining a channel without valid key $pool->on('user.can_join' => \&on_user_can_join, with_eo => 1, name => 'has.key'); - + return 1; } sub cmode_key { my ($channel, $mode) = @_; $mode->{has_basic_status} or return; - + # if we're unsetting... if (!$mode->{setting}) { return unless $channel->is_mode('key'); - + # if we unset without a parameter (the key), # we need to push the current key to params push @{ $mode->{params} }, $channel->mode_parameter('key') if !defined $mode->{param}; - + $channel->unset_mode('key'); } - + # setting. else { - + # sanity checking $mode->{param} = cols(cut_to_limit('key', $mode->{param})); - + # no length; don't set. if (!length $mode->{param}) { - $mode->{do_not_set} = 1; return; } - + $channel->set_mode('key', $mode->{param}); } - + return 1; } @@ -90,4 +89,3 @@ sub on_user_can_join { } $mod - diff --git a/modules/Core/ChannelModes.module/ChannelModes.json b/modules/Core/ChannelModes.module/ChannelModes.json index aec3dd1b..f6dbb4d1 100644 --- a/modules/Core/ChannelModes.module/ChannelModes.json +++ b/modules/Core/ChannelModes.module/ChannelModes.json @@ -12,5 +12,5 @@ "description" : "the core set of channel modes", "name" : "Core::ChannelModes", "package" : "M::Core::ChannelModes", - "version" : "9.86" + "version" : "10.99" } diff --git a/modules/Core/ChannelModes.module/ChannelModes.pm b/modules/Core/ChannelModes.module/ChannelModes.pm index fdadd12a..bf438292 100644 --- a/modules/Core/ChannelModes.module/ChannelModes.pm +++ b/modules/Core/ChannelModes.module/ChannelModes.pm @@ -33,13 +33,13 @@ sub init { # register status channel modes. register_statuses($_) or return foreach sort { $b <=> $a } keys %ircd::channel_mode_prefixes; - + # add multi-prefix capability. $mod->register_capability('multi-prefix'); # add channel message restrictions. add_message_restrictions(); - + return 1; } @@ -54,7 +54,7 @@ sub register_statuses { $mod->register_channel_mode_block( name => $name, code => sub { my ($channel, $mode) = @_; my $source = $mode->{source}; - + # find the target. my $t_user = $mode->{user_lookup}($mode->{param}); @@ -85,7 +85,7 @@ sub register_statuses { return 1; }; - + my $check2 = sub { # the source's highest status is not enough. @@ -99,7 +99,7 @@ sub register_statuses { $mode->{send_no_privs} = 1; return; } - + } # [USER RESPONSE, SERVER RESPONSE] @@ -108,9 +108,9 @@ sub register_statuses { # add or remove from the list. my $do = $mode->{state} ? 'add_to_list' : 'remove_from_list'; $channel->$do($name, $t_user); - + return 1; - + }) or return; return 1 @@ -148,7 +148,7 @@ sub _cmode_banlike { # view list. if (!length $mode->{param} && $mode->{source}->isa('user')) { - + # send each list item. my $name = uc($reply).q(LIST); my $letter = $me->cmode_letter($list); @@ -159,10 +159,10 @@ sub _cmode_banlike { $_->[1]{setby}, $_->[1]{time} ) foreach $channel->list_elements($list, 1); - + # end of list. $mode->{source}->numeric("RPL_ENDOF$name" => $channel->name); - + return; } @@ -171,11 +171,10 @@ sub _cmode_banlike { $mode->{send_no_privs} = 1; return; } - + # remove prefixing colon. $mode->{param} = cols($mode->{param}); if (!length $mode->{param}) { - $mode->{do_not_set} = 1; return; } @@ -191,7 +190,7 @@ sub _cmode_banlike { else { $channel->remove_from_list($list, $mode->{param}); } - + return 1; } @@ -200,29 +199,29 @@ sub add_message_restrictions { # not in channel and no external messages? $pool->on('user.can_message' => sub { my ($user, $event, $channel, $message, $type) = @_; - + # not internal only, or user is in channel. return unless $channel->is_mode('no_ext'); return if $channel->has_user($user); - + # no external messages. $user->numeric(ERR_CANNOTSENDTOCHAN => $channel->name, 'No external messages'); $event->stop('no_ext'); - + }, name => 'no.external.messages', with_eo => 1, priority => 30); - + # moderation and no voice? $pool->on('user.can_message' => sub { my ($user, $event, $channel, $message, $type) = @_; - + # not moderated, or the user has proper status. return unless $channel->is_mode('moderated'); return if $channel->user_get_highest_level($user) >= -2; - + # no external messages. $user->numeric(ERR_CANNOTSENDTOCHAN => $channel->name, 'Channel is moderated'); $event->stop('moderated'); - + }, name => 'moderated', with_eo => 1, priority => 20); # banned and no voice? @@ -238,7 +237,7 @@ sub add_message_restrictions { $event->stop('banned'); }, name => 'stop.banned.users', with_eo => 1, priority => 10); - + } $mod