Browse Source

Remove a little cruft.

Adam Ierymenko 8 years ago
parent
commit
4e77365e8d
2 changed files with 0 additions and 22 deletions
  1. 0 21
      controller/JSONDB.cpp
  2. 0 1
      controller/JSONDB.hpp

+ 0 - 21
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<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(),"/","",""));

+ 0 - 1
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