From be499328f6834c3ba5935fdd28d17b077be9f382 Mon Sep 17 00:00:00 2001 From: Hugo LAMY Date: Sun, 14 Aug 2022 01:17:55 +0200 Subject: [PATCH] fixed error in is_cgi, path was missing dot --- srcs/webserv/cgi_script.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/srcs/webserv/cgi_script.cpp b/srcs/webserv/cgi_script.cpp index c0cc85b..e1b4d52 100644 --- a/srcs/webserv/cgi_script.cpp +++ b/srcs/webserv/cgi_script.cpp @@ -3,9 +3,10 @@ bool Webserv::_is_cgi(Client *client, std::string path) { - size_t file_type; - size_t file_mode; - size_t pos = 0; + std::string script_path; + size_t file_type; + size_t file_mode; + size_t pos = 0; while (pos != NPOS) { @@ -14,17 +15,19 @@ bool Webserv::_is_cgi(Client *client, std::string path) if (pos == NPOS) break; client->fill_script_path(path, pos); - file_type = ::eval_file_type(client->get_rq_script_path()); + script_path = "." + client->get_rq_script_path(); + file_type = ::eval_file_type(script_path); if (file_type == IS_DIR) // but what if it's a symlink ? continue; if (file_type == IS_FILE) { - file_mode = ::eval_file_mode( client->get_rq_script_path(), X_OK ); + file_mode = ::eval_file_mode( script_path, X_OK ); if (!file_mode) return true; } } client->clear_script(); + client->clear_script(); client->status = file_mode; // 404 not_found OR 403 forbidden return false; }