diff --git a/config/default.conf b/config/default.conf index 076bb97..ea03b0e 100644 --- a/config/default.conf +++ b/config/default.conf @@ -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 } \ No newline at end of file diff --git a/webserv/config/AConfig.cpp b/webserv/config/AConfig.cpp index 1763fae..d4a27e4 100644 --- a/webserv/config/AConfig.cpp +++ b/webserv/config/AConfig.cpp @@ -1,5 +1,4 @@ #include // for AConfig - #include // for ADirective #include // for DirectiveFactory #include // 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; } diff --git a/webserv/config/directive/DirectiveFactory.hpp b/webserv/config/directive/DirectiveFactory.hpp index 5a17f0c..dab508c 100644 --- a/webserv/config/directive/DirectiveFactory.hpp +++ b/webserv/config/directive/DirectiveFactory.hpp @@ -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"}, diff --git a/webserv/config/directive/DirectiveValue.hpp b/webserv/config/directive/DirectiveValue.hpp index e7346cd..f5b2f54 100644 --- a/webserv/config/directive/DirectiveValue.hpp +++ b/webserv/config/directive/DirectiveValue.hpp @@ -21,7 +21,7 @@ using DirectiveValueType = std::variant, // index, allowed_methods, cgi_ext + std::vector, // index, allowed_methods, cgi_handler std::pair // error_page (status, path), redirect >; diff --git a/webserv/config/validation/ConfigValidator.cpp b/webserv/config/validation/ConfigValidator.cpp index 5eb66d2..039c3ef 100644 --- a/webserv/config/validation/ConfigValidator.cpp +++ b/webserv/config/validation/ConfigValidator.cpp @@ -1,5 +1,4 @@ #include - #include // for ValidationEngine #include // for AValidationRule #include // for AllowedValuesRule @@ -40,7 +39,7 @@ ConfigValidator::ConfigValidator(const GlobalConfig *config) : engine_(std::make engine_->addLocationRule("allowed_methods", std::make_unique( std::vector{"GET", "POST", "DELETE", "PUT"}, false)); // engine_->addLocationRule("root", std::make_unique(true)); - engine_->addLocationRule("cgi_ext", std::make_unique(false)); + engine_->addLocationRule("cgi_handler", std::make_unique(false)); // TODO: Add a validation rule for redirect diff --git a/webserv/config/validation/directive_rules/CgiExtValidationRule.cpp b/webserv/config/validation/directive_rules/CgiExtValidationRule.cpp index f9858c2..1ead6b9 100644 --- a/webserv/config/validation/directive_rules/CgiExtValidationRule.cpp +++ b/webserv/config/validation/directive_rules/CgiExtValidationRule.cpp @@ -17,7 +17,7 @@ CgiExtValidationRule::CgiExtValidationRule(bool requiresValue) bool isAllowedCGIExtension(const std::string &extension) { - static const std::vector allowedExtensions = {".php", ".py", ".bla", ".sh"}; + static const std::vector allowedExtensions = {".php", ".py", ".bla", ".sh", ".cgi"}; return std::ranges::any_of(allowedExtensions, [&extension](const auto &it) { return extension == it; }); }