Initial commit

Add .gitignore to exclude VSCode workspace files and build artifacts
This commit is contained in:
pmb
2025-06-24 15:28:09 -07:00
committed by pmb
parent 6291e7a501
commit f71f1c9b11
7 changed files with 415 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
#include "handler.hpp"
std::string process(const std::string &username){
try{
// Check for directory traversal patterns
if (username.find("../") != std::string::npos ||
username.find("..\\") != std::string::npos ||
username.find("%2e%2e%2f") != std::string::npos ||
username.find("%2e%2e%5c") != std::string::npos ||
username.find("%2E%2E%2F") != std::string::npos ||
username.find("%2E%2E%5C") != std::string::npos ||
username.find("..%2f") != std::string::npos ||
username.find("..%5c") != std::string::npos ||
username.find("..%2F") != std::string::npos ||
username.find("..%5C") != std::string::npos) {
throw InvalidInput("Directory traversal detected in username");
}
if (username.find("/") != std::string::npos){
throw InvalidInput("Path detected in username");
}
}
catch(InvalidInput&e){
return std::string("InvalidInput: ") + e.what() + std::string("\r\n");
}
return username;
}