Ensure that ex[3] is a valid length before continuing, creating a warning if invalid.
This commit is contained in:
1 parent
b133ef7a6f
commit
6e61841e20
1 file changed
+57
-52
+57
-52
@@ -529,76 +529,81 @@ sub privmsg
|
|||||||
# Check if it's to a channel or to us.
|
# Check if it's to a channel or to us.
|
||||||
if (lc($ex[2]) eq lc($botnick{$svr}{nick})) {
|
if (lc($ex[2]) eq lc($botnick{$svr}{nick})) {
|
||||||
# It is coming to us in a private message.
|
# It is coming to us in a private message.
|
||||||
$cmd = uc(substr($ex[3], 1));
|
|
||||||
if (defined $API::Std::CMDS{$cmd}) {
|
# Ensure it's a valid length.
|
||||||
# If this is indeed a command, continue.
|
if (length($ex[3]) > 1) {
|
||||||
if ($API::Std::CMDS{$cmd}{lvl} == 1 or $API::Std::CMDS{$cmd}{lvl} == 2) {
|
$cmd = uc(substr($ex[3], 1));
|
||||||
# Ensure the level is private or all.
|
if (defined $API::Std::CMDS{$cmd}) {
|
||||||
if (!defined $Core::IRC::usercmd{$data{nick}.'@'.$data{host}}) { $Core::IRC::usercmd{$data{nick}.'@'.$data{host}} = 0; }
|
# If this is indeed a command, continue.
|
||||||
if (API::Std::ratelimit_check(%data)) {
|
if ($API::Std::CMDS{$cmd}{lvl} == 1 or $API::Std::CMDS{$cmd}{lvl} == 2) {
|
||||||
# Continue if the user has not passed the ratelimit amount.
|
# Ensure the level is private or all.
|
||||||
if ($API::Std::CMDS{$cmd}{priv}) {
|
if (API::Std::ratelimit_check(%data)) {
|
||||||
# If this command requires a privilege...
|
# Continue if the user has not passed the ratelimit amount.
|
||||||
if (API::Std::has_priv(API::Std::match_user(%data), $API::Std::CMDS{$cmd}{priv})) {
|
if ($API::Std::CMDS{$cmd}{priv}) {
|
||||||
# Make sure they have it.
|
# If this command requires a privilege...
|
||||||
&{ $API::Std::CMDS{$cmd}{'sub'} }(%data);
|
if (API::Std::has_priv(API::Std::match_user(%data), $API::Std::CMDS{$cmd}{priv})) {
|
||||||
|
# Make sure they have it.
|
||||||
|
&{ $API::Std::CMDS{$cmd}{'sub'} }(%data);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# Else give them the boot.
|
||||||
|
API::IRC::notice($data{svr}, $data{nick}, API::Std::trans("Permission denied").".");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# Else give them the boot.
|
# Else execute the command without any extra checks.
|
||||||
API::IRC::notice($data{svr}, $data{nick}, API::Std::trans("Permission denied").".");
|
&{ $API::Std::CMDS{$cmd}{'sub'} }(%data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# Else execute the command without any extra checks.
|
# Send them a notice about their bad deed.
|
||||||
&{ $API::Std::CMDS{$cmd}{'sub'} }(%data);
|
API::IRC::notice($data{svr}, $data{nick}, trans('Rate limit exceeded').q{.});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
}
|
||||||
# Send them a notice about their bad deed.
|
}
|
||||||
API::IRC::notice($data{svr}, $data{nick}, trans('Rate limit exceeded').q{.});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Trigger event on_uprivmsg.
|
# Trigger event on_uprivmsg.
|
||||||
API::Std::event_run("on_uprivmsg", ($svr, @ex));
|
API::Std::event_run("on_uprivmsg", ($svr, @ex));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# It is coming to us in a channel message.
|
# It is coming to us in a channel message.
|
||||||
$data{chan} = $ex[2];
|
$data{chan} = $ex[2];
|
||||||
$cprefix = (conf_get("fantasy_pf"))[0][0];
|
# Ensure it's a valid length before continuing.
|
||||||
$rprefix = substr($ex[3], 1, 1);
|
if (length($ex[3]) > 1) {
|
||||||
$cmd = uc(substr($ex[3], 2));
|
$cprefix = (conf_get("fantasy_pf"))[0][0];
|
||||||
if (defined $API::Std::CMDS{$cmd}) {
|
$rprefix = substr($ex[3], 1, 1);
|
||||||
# If this is indeed a command, continue.
|
$cmd = uc(substr($ex[3], 2));
|
||||||
if ($API::Std::CMDS{$cmd}{lvl} == 0 or $API::Std::CMDS{$cmd}{lvl} == 2) {
|
if (defined $API::Std::CMDS{$cmd}) {
|
||||||
# Ensure the level is public or all.
|
# If this is indeed a command, continue.
|
||||||
if (!defined $Core::IRC::usercmd{$data{nick}.'@'.$data{host}}) { $Core::IRC::usercmd{$data{nick}.'@'.$data{host}} = 0; }
|
if ($API::Std::CMDS{$cmd}{lvl} == 0 or $API::Std::CMDS{$cmd}{lvl} == 2) {
|
||||||
if (API::Std::ratelimit_check(%data)) {
|
# Ensure the level is public or all.
|
||||||
# Continue if the user has not passed the ratelimit amount.
|
if (API::Std::ratelimit_check(%data)) {
|
||||||
if ($API::Std::CMDS{$cmd}{priv}) {
|
# Continue if the user has not passed the ratelimit amount.
|
||||||
# If this command takes a privilege...
|
if ($API::Std::CMDS{$cmd}{priv}) {
|
||||||
if (API::Std::has_priv(API::Std::match_user(%data), $API::Std::CMDS{$cmd}{priv})) {
|
# If this command takes a privilege...
|
||||||
# Make sure they have it.
|
if (API::Std::has_priv(API::Std::match_user(%data), $API::Std::CMDS{$cmd}{priv})) {
|
||||||
&{ $API::Std::CMDS{$cmd}{'sub'} }(%data) if $rprefix eq $cprefix;
|
# Make sure they have it.
|
||||||
|
&{ $API::Std::CMDS{$cmd}{'sub'} }(%data) if $rprefix eq $cprefix;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# Else give them the boot.
|
||||||
|
API::IRC::notice($data{svr}, $data{nick}, API::Std::trans("Permission denied").".");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# Else give them the boot.
|
# Else continue executing without any extra checks.
|
||||||
API::IRC::notice($data{svr}, $data{nick}, API::Std::trans("Permission denied").".");
|
&{ $API::Std::CMDS{$cmd}{'sub'} }(%data) if $rprefix eq $cprefix;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# Else continue executing without any extra checks.
|
# Send them a notice about their bad deed.
|
||||||
&{ $API::Std::CMDS{$cmd}{'sub'} }(%data) if $rprefix eq $cprefix;
|
API::IRC::notice($data{svr}, $data{nick}, trans('Rate limit exceeded').q{.});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
}
|
||||||
# Send them a notice about their bad deed.
|
}
|
||||||
API::IRC::notice($data{svr}, $data{nick}, trans('Rate limit exceeded').q{.});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Trigger event on_cprivmsg.
|
# Trigger event on_cprivmsg.
|
||||||
API::Std::event_run("on_cprivmsg", ($svr, @ex));
|
API::Std::event_run("on_cprivmsg", ($svr, @ex));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user