mirror of
https://github.com/anope/anope.git
synced 2026-06-29 18:56:37 +02:00
Fix various commands to properly report a given expiry time is invalid
This commit is contained in:
@@ -104,7 +104,21 @@ class CommandBSSetBanExpire : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
ci->banexpire = Anope::DoTime(arg);
|
||||
time_t t = Anope::DoTime(arg);
|
||||
if (t == -1)
|
||||
{
|
||||
source.Reply(BAD_EXPIRY_TIME);
|
||||
return;
|
||||
}
|
||||
|
||||
/* cap at 1 day */
|
||||
if (t > 86400)
|
||||
{
|
||||
source.Reply(_("Ban expiry may not be longer than 1 day."));
|
||||
return;
|
||||
}
|
||||
|
||||
ci->banexpire = t;
|
||||
|
||||
bool override = !access.HasPriv("SET");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to change banexpire to " << ci->banexpire;
|
||||
|
||||
@@ -69,6 +69,11 @@ class CommandCSBan : public Command
|
||||
if (params[1][0] == '+')
|
||||
{
|
||||
ban_time = Anope::DoTime(params[1]);
|
||||
if (ban_time == -1)
|
||||
{
|
||||
source.Reply(BAD_EXPIRY_TIME);
|
||||
return;
|
||||
}
|
||||
if (params.size() < 3)
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
|
||||
@@ -73,7 +73,14 @@ class CommandCSSuspend : public Command
|
||||
expiry.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
expiry_secs = Anope::DoTime(expiry);
|
||||
if (expiry_secs == -1)
|
||||
{
|
||||
source.Reply(BAD_EXPIRY_TIME);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (Anope::ReadOnly)
|
||||
source.Reply(READ_ONLY_MODE);
|
||||
|
||||
@@ -79,7 +79,14 @@ class CommandNSSuspend : public Command
|
||||
expiry.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
expiry_secs = Anope::DoTime(expiry);
|
||||
if (expiry_secs == -1)
|
||||
{
|
||||
source.Reply(BAD_EXPIRY_TIME);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
NickAlias *na = NickAlias::Find(nick);
|
||||
if (!na)
|
||||
|
||||
@@ -137,7 +137,12 @@ class CommandOSForbid : public Command
|
||||
if (!expiry.empty())
|
||||
{
|
||||
expiryt = Anope::DoTime(expiry);
|
||||
if (expiryt)
|
||||
if (expiryt == -1)
|
||||
{
|
||||
source.Reply(BAD_EXPIRY_TIME);
|
||||
return;
|
||||
}
|
||||
else if (expiryt)
|
||||
expiryt += Anope::CurTime;
|
||||
}
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ class CommandOSIgnore : public Command
|
||||
|
||||
if (t <= -1)
|
||||
{
|
||||
source.Reply(_("You have to enter a valid number as time."));
|
||||
source.Reply(BAD_EXPIRY_TIME);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -176,8 +176,8 @@ class CommandOSIgnore : public Command
|
||||
}
|
||||
else
|
||||
{
|
||||
source.Reply(_("\002%s\002 will now be ignored for \002%s\002."), nick.c_str(), time.c_str());
|
||||
Log(LOG_ADMIN, source, this) << "to add an ignore on " << nick << " for " << time;
|
||||
source.Reply(_("\002%s\002 will now be ignored for \002%s\002."), nick.c_str(), Anope::Duration(t, source.GetAccount()).c_str());
|
||||
Log(LOG_ADMIN, source, this) << "to add an ignore on " << nick << " for " << Anope::Duration(t, source.GetAccount());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -294,7 +294,10 @@ time_t Anope::DoTime(const Anope::string &s)
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const ConvertException &) { }
|
||||
catch (const ConvertException &)
|
||||
{
|
||||
amount = -1;
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user