mirror of
https://github.com/anope/anope.git
synced 2026-07-08 07:43:15 +02:00
The first of a few "CBX OCDing over code style" commits, focusing on include/* and src/* but not src/core/* or src/modules/*.
This commit is contained in:
+13
-18
@@ -14,9 +14,7 @@ void MailThread::Run()
|
||||
FILE *pipe = popen(Config.SendMailPath, "w");
|
||||
|
||||
if (!pipe)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(pipe, "From: %s\n", Config.SendFrom);
|
||||
if (Config.DontQuoteAddresses)
|
||||
@@ -26,7 +24,7 @@ void MailThread::Run()
|
||||
fprintf(pipe, "Subject: %s\n", Subject.c_str());
|
||||
fprintf(pipe, "%s", Message.c_str());
|
||||
fprintf(pipe, "\n.\n");
|
||||
|
||||
|
||||
pclose(pipe);
|
||||
|
||||
Success = true;
|
||||
@@ -36,9 +34,9 @@ bool Mail(User *u, NickRequest *nr, const std::string &service, const std::strin
|
||||
{
|
||||
if (!u || !nr || subject.empty() || service.empty() || message.empty())
|
||||
return false;
|
||||
|
||||
|
||||
time_t t = time(NULL);
|
||||
|
||||
|
||||
if (!Config.UseMail)
|
||||
notice_lang(service.c_str(), u, MAIL_DISABLED);
|
||||
else if (t - u->lastmail < Config.MailDelay)
|
||||
@@ -59,7 +57,7 @@ bool Mail(User *u, NickCore *nc, const std::string &service, const std::string &
|
||||
{
|
||||
if (!u || !nc || subject.empty() || service.empty() || message.empty())
|
||||
return false;
|
||||
|
||||
|
||||
time_t t = time(NULL);
|
||||
|
||||
if (!Config.UseMail)
|
||||
@@ -82,7 +80,7 @@ bool Mail(NickCore *nc, const std::string &subject, const std::string &message)
|
||||
{
|
||||
if (!Config.UseMail || !nc || !nc->email || subject.empty() || message.empty())
|
||||
return false;
|
||||
|
||||
|
||||
nc->lastmail = time(NULL);
|
||||
threadEngine.Start(new MailThread(nc->display, nc->email, subject, message));
|
||||
|
||||
@@ -103,14 +101,12 @@ bool MailValidate(const std::string &email)
|
||||
bool has_period = false;
|
||||
char copy[BUFSIZE];
|
||||
|
||||
static char specials[] = {
|
||||
'(', ')', '<', '>', '@', ',', ';', ':', '\\', '\"', '[', ']', ' '
|
||||
};
|
||||
static char specials[] = {'(', ')', '<', '>', '@', ',', ';', ':', '\\', '\"', '[', ']', ' '};
|
||||
|
||||
if (email.empty())
|
||||
return false;
|
||||
strlcpy(copy, email.c_str(), sizeof(copy));
|
||||
|
||||
|
||||
char *domain = strchr(copy, '@');
|
||||
if (!domain)
|
||||
return false;
|
||||
@@ -119,28 +115,28 @@ bool MailValidate(const std::string &email)
|
||||
/* Don't accept NULL copy or domain. */
|
||||
if (!*copy || !*domain)
|
||||
return false;
|
||||
|
||||
|
||||
/* Check for forbidden characters in the name */
|
||||
for (unsigned int i = 0; i < strlen(copy); i++)
|
||||
for (unsigned int i = 0; i < strlen(copy); ++i)
|
||||
{
|
||||
if (copy[i] <= 31 || copy[i] >= 127)
|
||||
return false;
|
||||
for (unsigned int j = 0; j < 13; j++)
|
||||
for (unsigned int j = 0; j < 13; ++j)
|
||||
if (copy[i] == specials[j])
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Check for forbidden characters in the domain */
|
||||
for (unsigned int i = 0; i < strlen(domain); i++)
|
||||
for (unsigned int i = 0; i < strlen(domain); ++i)
|
||||
{
|
||||
if (domain[i] <= 31 || domain[i] >= 127)
|
||||
return false;
|
||||
for (unsigned int j = 0; j < 13; j++)
|
||||
for (unsigned int j = 0; j < 13; ++j)
|
||||
if (domain[i] == specials[j])
|
||||
return false;
|
||||
if (domain[i] == '.')
|
||||
{
|
||||
if (i == 0 || i == strlen(domain) - 1)
|
||||
if (!i || i == strlen(domain) - 1)
|
||||
return false;
|
||||
has_period = true;
|
||||
}
|
||||
@@ -148,4 +144,3 @@ bool MailValidate(const std::string &email)
|
||||
|
||||
return has_period;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user