fixed error in is_cgi, path was missing dot

This commit is contained in:
Hugo LAMY
2022-08-14 01:17:55 +02:00
parent 41db4fc12b
commit be499328f6

View File

@@ -3,6 +3,7 @@
bool Webserv::_is_cgi(Client *client, std::string path) bool Webserv::_is_cgi(Client *client, std::string path)
{ {
std::string script_path;
size_t file_type; size_t file_type;
size_t file_mode; size_t file_mode;
size_t pos = 0; size_t pos = 0;
@@ -14,17 +15,19 @@ bool Webserv::_is_cgi(Client *client, std::string path)
if (pos == NPOS) if (pos == NPOS)
break; break;
client->fill_script_path(path, pos); 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 ? if (file_type == IS_DIR) // but what if it's a symlink ?
continue; continue;
if (file_type == IS_FILE) 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) if (!file_mode)
return true; return true;
} }
} }
client->clear_script(); client->clear_script();
client->clear_script();
client->status = file_mode; // 404 not_found OR 403 forbidden client->status = file_mode; // 404 not_found OR 403 forbidden
return false; return false;
} }