mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-04-20 08:50:49 +00:00
Remove a little cruft.
This commit is contained in:
parent
4f2a779769
commit
4e77365e8d
@ -55,8 +55,6 @@ JSONDB::JSONDB(const std::string &basePath) :
|
||||
|
||||
bool JSONDB::writeRaw(const std::string &n,const std::string &obj)
|
||||
{
|
||||
if (!_isValidObjectName(n))
|
||||
return false;
|
||||
if (_httpAddr) {
|
||||
std::map<std::string,std::string> headers;
|
||||
std::string body;
|
||||
@ -92,9 +90,6 @@ nlohmann::json JSONDB::get(const std::string &n)
|
||||
_reload(_basePath,std::string());
|
||||
}
|
||||
|
||||
if (!_isValidObjectName(n))
|
||||
return _EMPTY_JSON;
|
||||
|
||||
{
|
||||
Mutex::Lock _l(_db_m);
|
||||
std::map<std::string,_E>::iterator e(_db.find(n));
|
||||
@ -131,8 +126,6 @@ nlohmann::json JSONDB::get(const std::string &n)
|
||||
|
||||
void JSONDB::erase(const std::string &n)
|
||||
{
|
||||
if (!_isValidObjectName(n))
|
||||
return;
|
||||
_erase(n);
|
||||
{
|
||||
Mutex::Lock _l(_db_m);
|
||||
@ -190,20 +183,6 @@ void JSONDB::_reload(const std::string &p,const std::string &b)
|
||||
}
|
||||
}
|
||||
|
||||
bool JSONDB::_isValidObjectName(const std::string &n)
|
||||
{
|
||||
if (n.length() == 0)
|
||||
return false;
|
||||
const char *p = n.c_str();
|
||||
char c;
|
||||
// For security reasons we should not allow dots, backslashes, or other path characters or potential path characters.
|
||||
while ((c = *(p++))) {
|
||||
if (!( ((c >= 'a')&&(c <= 'z')) || ((c >= 'A')&&(c <= 'Z')) || ((c >= '0')&&(c <= '9')) || (c == '/') || (c == '_') || (c == '~') || (c == '-') ))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string JSONDB::_genPath(const std::string &n,bool create)
|
||||
{
|
||||
std::vector<std::string> pt(OSUtils::split(n.c_str(),"/","",""));
|
||||
|
@ -94,7 +94,6 @@ public:
|
||||
private:
|
||||
void _erase(const std::string &n);
|
||||
void _reload(const std::string &p,const std::string &b);
|
||||
bool _isValidObjectName(const std::string &n);
|
||||
std::string _genPath(const std::string &n,bool create);
|
||||
|
||||
struct _E
|
||||
|
Loading…
x
Reference in New Issue
Block a user