fixed: misc: ValidateEmail() buffer overflow
added: notifications for resetting a user's password (there is no a winix function for this yet) git-svn-id: svn://ttmath.org/publicrep/winix/trunk@817 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -234,7 +234,8 @@ void Config::AssignValues(bool stdout_is_closed)
|
||||
ezc_max_elements = Size(L"ezc_max_elements", 50000);
|
||||
ezc_max_loop_elements = Size(L"ezc_max_loop_elements", 5000);
|
||||
|
||||
account_need_email_verification = Bool(L"account_need_email_verification", true);
|
||||
account_need_email_verification = Bool(L"account_need_email_verification", true);
|
||||
reset_password_code_expiration_time = Long(L"reset_password_code_expiration_time", 86400);
|
||||
}
|
||||
|
||||
|
||||
@@ -366,6 +367,23 @@ int Config::Int(const std::wstring & name, int def)
|
||||
}
|
||||
|
||||
|
||||
long Config::Long(const wchar_t * name)
|
||||
{
|
||||
return space.Long(name);
|
||||
}
|
||||
|
||||
long Config::Long(const wchar_t * name, long def)
|
||||
{
|
||||
return space.Long(name, def);
|
||||
}
|
||||
|
||||
long Config::Long(const std::wstring & name, long def)
|
||||
{
|
||||
return space.Long(name, def);
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_t Config::Size(const wchar_t * name)
|
||||
{
|
||||
return space.Size(name);
|
||||
|
@@ -472,6 +472,11 @@ public:
|
||||
// default: true
|
||||
bool account_need_email_verification;
|
||||
|
||||
// when a user forgot his password we are able to send an email to him
|
||||
// with a link to the page where there is a html form for setting a new password
|
||||
// this option tells how long (in seconds) the link is valid
|
||||
// default: 86400 (24 hours)
|
||||
long reset_password_code_expiration_time;
|
||||
|
||||
|
||||
Config();
|
||||
@@ -484,9 +489,12 @@ public:
|
||||
std::string & AText(const wchar_t * name, const char * def);
|
||||
std::string & AText(const std::wstring & name, const char * def);
|
||||
|
||||
int Int(const wchar_t *);
|
||||
int Int(const wchar_t * name, int def);
|
||||
int Int(const std::wstring & name, int def);
|
||||
int Int(const wchar_t *);
|
||||
int Int(const wchar_t * name, int def);
|
||||
int Int(const std::wstring & name, int def);
|
||||
long Long(const wchar_t *);
|
||||
long Long(const wchar_t * name, long def);
|
||||
long Long(const std::wstring & name, long def);
|
||||
size_t Size(const wchar_t *);
|
||||
size_t Size(const wchar_t * name, size_t def);
|
||||
size_t Size(const std::wstring & name, size_t def);
|
||||
|
@@ -622,48 +622,65 @@ std::wstring::size_type i;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool IsEmailCorrectChar(wchar_t c)
|
||||
{
|
||||
bool correct = false;
|
||||
|
||||
const wchar_t * allowed_chars = L"@.!#$%&'*+-/=?^_`{|}~";
|
||||
|
||||
bool ValidateEmail(const std::wstring & email)
|
||||
{
|
||||
if( email.empty() )
|
||||
return false;
|
||||
|
||||
bool correct = true;
|
||||
size_t i;
|
||||
wchar_t allowed_chars[] = L"!#$%&'*+-/=?^_`{|}~.@";
|
||||
int at = 0;
|
||||
|
||||
for(i=0 ; i<email.length() && correct ; ++i)
|
||||
if( (c >= 'A' && c<='Z') ||
|
||||
(c >= 'a' && c<='z') ||
|
||||
(c >= '0' && c<='9') )
|
||||
{
|
||||
correct = false;
|
||||
|
||||
if( (email[i] >= 'A' && email[i]<='Z') ||
|
||||
(email[i] >= 'a' && email[i]<='z') ||
|
||||
(email[i] >= '0' && email[i]<='9') )
|
||||
correct = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for(size_t a=0 ; allowed_chars[a] != 0 ; ++a)
|
||||
{
|
||||
correct = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for(size_t a=0 ; a < sizeof(allowed_chars)-1 ; ++a)
|
||||
if( c == allowed_chars[a] )
|
||||
{
|
||||
if( email[i] == allowed_chars[a] )
|
||||
{
|
||||
correct = true;
|
||||
break;
|
||||
}
|
||||
correct = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return correct;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool ValidateEmail(const wchar_t * email)
|
||||
{
|
||||
int at = 0; // how many '@'
|
||||
int dots_after_at = 0; // how many dots in the domain part
|
||||
|
||||
for(size_t i=0 ; email[i] != 0 ; ++i)
|
||||
{
|
||||
if( !IsEmailCorrectChar(email[i]) )
|
||||
return false;
|
||||
|
||||
if( email[i] == '@' )
|
||||
++at;
|
||||
|
||||
if( email[i] == '.' && at > 0 )
|
||||
++dots_after_at;
|
||||
}
|
||||
|
||||
if( at != 1 )
|
||||
if( at != 1 || dots_after_at == 0 )
|
||||
return false;
|
||||
|
||||
return correct;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool ValidateEmail(const std::wstring & email)
|
||||
{
|
||||
return ValidateEmail(email.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -591,7 +591,8 @@ return str + i;
|
||||
|
||||
|
||||
|
||||
|
||||
bool IsEmailCorrectChar(wchar_t c);
|
||||
bool ValidateEmail(const wchar_t * email);
|
||||
bool ValidateEmail(const std::wstring & email);
|
||||
|
||||
bool IsFile(const wchar_t * file);
|
||||
|
@@ -54,7 +54,7 @@
|
||||
#define WINIX_SESSION_CHANGED 30020
|
||||
|
||||
// the winix is closing
|
||||
// the is not any session available (cur->session is null)
|
||||
// there is not any sessions available (cur->session is null)
|
||||
#define WINIX_CLOSE 30040
|
||||
|
||||
// preparing to remove a file (rm function)
|
||||
|
Reference in New Issue
Block a user