Archived
1
0
This repository has been archived on 2023-08-12. You can view files and clone it, but cannot push or open issues or pull requests.
nntpchan/contrib/backends/nntpchan-daemon/src/message.cpp

29 lines
695 B
C++
Raw Normal View History

2016-10-15 18:12:01 +05:00
#include "message.hpp"
namespace nntpchan
{
2017-05-03 22:33:04 +05:00
bool IsValidMessageID(const std::string & msgid)
2016-10-15 18:12:01 +05:00
{
2017-05-03 22:33:04 +05: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 18:12:01 +05:00
bool atfound = false;
while(itr != end) {
auto c = *itr;
++itr;
if(atfound && c == '@') return false;
if(c == '@') {
atfound = true;
continue;
}
2017-05-03 22:33:04 +05: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 18:12:01 +05:00
return false;
}
return true;
}
}