diff --git a/controller/JSONDB.cpp b/controller/JSONDB.cpp index 509250b95..1055b0365 100644 --- a/controller/JSONDB.cpp +++ b/controller/JSONDB.cpp @@ -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 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::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 pt(OSUtils::split(n.c_str(),"/","","")); diff --git a/controller/JSONDB.hpp b/controller/JSONDB.hpp index a045d1b45..09667cf05 100644 --- a/controller/JSONDB.hpp +++ b/controller/JSONDB.hpp @@ -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