This repository has been archived on 2023-08-12. You can view files and clone it. You cannot open issues or pull requests or push a commit.
2016-10-15 09:12:01 -04:00
|
|
|
#include "message.hpp"
|
|
|
|
|
|
|
|
|
|
namespace nntpchan
|
|
|
|
|
{
|
2017-05-03 13:33:04 -04:00
|
|
|
bool IsValidMessageID(const std::string & msgid)
|
2016-10-15 09:12:01 -04:00
|
|
|
{
|
2017-05-03 13:33:04 -04:00
|
|
|
if(msgid[0] != '<') return false;
|
|
|
|
|
if(msgid[msgid.size()-1] != '>') return false;
|
|
|
|
|
auto itr = msgid.begin() + 1;
|
|
|
|
|
auto end = msgid.end() - 1;
|
2016-10-15 09:12:01 -04:00
|
|
|
bool atfound = false;
|
|
|
|
|
while(itr != end) {
|
|
|
|
|
auto c = *itr;
|
|
|
|
|
++itr;
|
|
|
|
|
if(atfound && c == '@') return false;
|
|
|
|
|
if(c == '@') {
|
|
|
|
|
atfound = true;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2017-05-03 13:33:04 -04:00
|
|
|
if (c == '$' || c == '_' || c == '-' || c == '.') continue;
|
|
|
|
|
if (c >= '0' && c <= '9') continue;
|
|
|
|
|
if (c >= 'A' && c <= 'Z') continue;
|
|
|
|
|
if (c >= 'a' && c <= 'z') continue;
|
2016-10-15 09:12:01 -04:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|