--- parser3/src/targets/cgi/parser3.C 2020/11/13 23:34:10 1.313 +++ parser3/src/targets/cgi/parser3.C 2020/11/16 14:52:19 1.315 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -volatile const char * IDENT_PARSER3_C="$Id: parser3.C,v 1.313 2020/11/13 23:34:10 moko Exp $"; +volatile const char * IDENT_PARSER3_C="$Id: parser3.C,v 1.315 2020/11/16 14:52:19 moko Exp $"; #include "pa_config_includes.h" @@ -178,7 +178,7 @@ size_t SAPI::send_body(SAPI_Info& info, return info.send_body(buf, size); } -static void full_file_spec(const char* file_name, char *buf, size_t buf_size) { +static void full_disk_path(const char* file_name, char *buf, size_t buf_size) { if(file_name[0]=='/' #ifdef WIN32 || file_name[0] && file_name[1]==':' @@ -276,7 +276,7 @@ static void connection_handler(SAPI_Info memset(&request_info, 0, sizeof(request_info)); char document_root_buf[MAX_STRING]; - full_file_spec("", document_root_buf, sizeof(document_root_buf)); + full_disk_path("", document_root_buf, sizeof(document_root_buf)); request_info.document_root = document_root_buf; request_info.path_translated = filespec_to_process; request_info.method = connection.method(); @@ -387,18 +387,10 @@ static void real_parser_handler() { if(strncmp(request_info.uri, script_name, script_name_len)==0 && script_name_len != uri_len) // under IIS they are the same SAPI::die("CGI: illegal call (1)"); } else { // fcgiwrap minimalistic setup - - if(request_info.query_string && *request_info.query_string) { - char* reconstructed_uri = new(PointerFreeGC) char[strlen(path_info) + 1/*'?'*/+ strlen(request_info.query_string) + 1/*0*/]; - strcpy(reconstructed_uri, path_info); - strcat(reconstructed_uri, "?"); - strcat(reconstructed_uri, request_info.query_string); - request_info.uri = reconstructed_uri; - } else - request_info.uri = path_info; + request_info.uri = request_info.query_string && *request_info.query_string ? pa_strcat(path_info, "?", request_info.query_string) : path_info; } } else{ - full_file_spec("", document_root_buf, sizeof(document_root_buf)); + full_disk_path("", document_root_buf, sizeof(document_root_buf)); request_info.document_root = document_root_buf; request_info.uri = ""; } @@ -615,7 +607,7 @@ int main(int argc, char *argv[]) { char filespec_to_process_buf[MAX_STRING]; if(raw_filespec_to_process && *raw_filespec_to_process){ - full_file_spec(raw_filespec_to_process, filespec_to_process_buf, sizeof(filespec_to_process_buf)); + full_disk_path(raw_filespec_to_process, filespec_to_process_buf, sizeof(filespec_to_process_buf)); filespec_to_process=filespec_to_process_buf; }