change cgi_ext to cgi_handler
This commit is contained in:
parent
895ad1481b
commit
334c378d23
@ -67,7 +67,7 @@ server {
|
||||
}
|
||||
|
||||
# cgi_enabled yes;
|
||||
# cgi_ext .php /usr/bin/php-cgi;
|
||||
# cgi_handler .php /usr/bin/php-cgi;
|
||||
}
|
||||
|
||||
server {
|
||||
@ -101,7 +101,7 @@ server {
|
||||
# }
|
||||
|
||||
# cgi_enabled yes;
|
||||
cgi_ext .php /usr/bin/php-cgi;
|
||||
cgi_handler .php /usr/bin/php-cgi;
|
||||
}
|
||||
|
||||
server {
|
||||
@ -121,7 +121,7 @@ server {
|
||||
}
|
||||
|
||||
cgi_enabled yes;
|
||||
cgi_ext .php /usr/bin/php-cgi;
|
||||
cgi_handler .php /usr/bin/php-cgi;
|
||||
}
|
||||
|
||||
server {
|
||||
@ -156,5 +156,5 @@ server {
|
||||
}
|
||||
|
||||
cgi_enabled yes;
|
||||
cgi_ext .bla ./ubuntu_cgi_tester
|
||||
cgi_handler .bla ./ubuntu_cgi_tester
|
||||
}
|
||||
@ -1,5 +1,4 @@
|
||||
#include <webserv/config/AConfig.hpp> // for AConfig
|
||||
|
||||
#include <webserv/config/directive/ADirective.hpp> // for ADirective
|
||||
#include <webserv/config/directive/DirectiveFactory.hpp> // for DirectiveFactory
|
||||
#include <webserv/config/directive/DirectiveValue.hpp> // for DirectiveValue
|
||||
@ -120,7 +119,7 @@ std::string AConfig::getCGIPath(const std::string &extension) const
|
||||
Log::trace(LOCATION);
|
||||
for (const auto &directive : directives_)
|
||||
{
|
||||
if (directive->getName() != "cgi_ext")
|
||||
if (directive->getName() != "cgi_handler")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ class DirectiveFactory
|
||||
{.name = "autoindex", .type = "BoolDirective", .context = "gsl"},
|
||||
{.name = "allowed_methods", .type = "VectorDirective", .context = "gsl"},
|
||||
{.name = "cgi_enabled", .type = "BoolDirective", .context = "gsl"},
|
||||
{.name = "cgi_ext", .type = "VectorDirective", .context = "gsl"},
|
||||
{.name = "cgi_handler", .type = "VectorDirective", .context = "gsl"},
|
||||
{.name = "cgi_timeout", .type = "IntDirective", .context = "gsl"},
|
||||
{.name = "upload_enabled", .type = "BoolDirective", .context = "gsl"},
|
||||
{.name = "upload_store", .type = "StringDirective", .context = "gsl"},
|
||||
|
||||
@ -21,7 +21,7 @@ using DirectiveValueType = std::variant<int, // listen, error_page status, cgi_t
|
||||
size_t,
|
||||
bool, // autoindex, upload_enabled
|
||||
std::string, // host, server_name, root, cgi_pass, upload_store
|
||||
std::vector<std::string>, // index, allowed_methods, cgi_ext
|
||||
std::vector<std::string>, // index, allowed_methods, cgi_handler
|
||||
std::pair<int, std::string> // error_page (status, path), redirect
|
||||
>;
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
#include <webserv/config/validation/ConfigValidator.hpp>
|
||||
|
||||
#include <webserv/config/validation/ValidationEngine.hpp> // for ValidationEngine
|
||||
#include <webserv/config/validation/directive_rules/AValidationRule.hpp> // for AValidationRule
|
||||
#include <webserv/config/validation/directive_rules/AllowedValuesRule.hpp> // for AllowedValuesRule
|
||||
@ -40,7 +39,7 @@ ConfigValidator::ConfigValidator(const GlobalConfig *config) : engine_(std::make
|
||||
engine_->addLocationRule("allowed_methods", std::make_unique<AllowedValuesRule>(
|
||||
std::vector<std::string>{"GET", "POST", "DELETE", "PUT"}, false));
|
||||
// engine_->addLocationRule("root", std::make_unique<FolderExistsRule>(true));
|
||||
engine_->addLocationRule("cgi_ext", std::make_unique<CgiExtValidationRule>(false));
|
||||
engine_->addLocationRule("cgi_handler", std::make_unique<CgiExtValidationRule>(false));
|
||||
|
||||
// TODO: Add a validation rule for redirect
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ CgiExtValidationRule::CgiExtValidationRule(bool requiresValue)
|
||||
|
||||
bool isAllowedCGIExtension(const std::string &extension)
|
||||
{
|
||||
static const std::vector<std::string> allowedExtensions = {".php", ".py", ".bla", ".sh"};
|
||||
static const std::vector<std::string> allowedExtensions = {".php", ".py", ".bla", ".sh", ".cgi"};
|
||||
return std::ranges::any_of(allowedExtensions, [&extension](const auto &it) { return extension == it; });
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user