--- parser3/src/targets/isapi/parser3isapi.C 2020/10/26 23:15:52 1.118 +++ parser3/src/targets/isapi/parser3isapi.C 2020/12/01 21:32:10 1.121 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -volatile const char * IDENT_PARSER3ISAPI_C="$Id: parser3isapi.C,v 1.118 2020/10/26 23:15:52 moko Exp $"; +volatile const char * IDENT_PARSER3ISAPI_C="$Id: parser3isapi.C,v 1.121 2020/12/01 21:32:10 moko Exp $"; #ifndef _MSC_VER # error compile ISAPI module with MSVC [no urge for now to make it autoconf-ed (PAF)] @@ -138,11 +138,7 @@ static int grep_char(const char* s, char } return result; } -static const char* mk_env_pair(const char* key, const char* value) { - char *result=new(PointerFreeGC) char[strlen(key)+1/*=*/+strlen(value)+1/*0*/]; - strcpy(result, key); strcat(result, "="); strcat(result, value); - return result; -} + const char* const *SAPI::Env::get(SAPI_Info& info) { // we know this buf is writable char* all_http_vars=SAPI::Env::get(info, "ALL_HTTP"); @@ -155,7 +151,7 @@ const char* const *SAPI::Env::get(SAPI_I for(int i=0; ilpszExtensionDesc, "Parser " PARSER_VERSION, HSE_MAX_EXT_DLL_NAME_LEN-1); pVer->lpszExtensionDesc[HSE_MAX_EXT_DLL_NAME_LEN-1]=0; return parser_init(); } @@ -328,53 +324,32 @@ void real_parser_handler(SAPI_Info& SAPI strncpy(buf, filespec_to_process, len); buf[len]=0; request_info.document_root=buf; } else - throw Exception(PARSER_RUNTIME, - 0, - "ISAPI: no PATH_INFO defined (in reinventing DOCUMENT_ROOT)"); + throw Exception(PARSER_RUNTIME, 0, "ISAPI: no PATH_INFO defined (in reinventing DOCUMENT_ROOT)"); request_info.path_translated=filespec_to_process; request_info.method=lpECB->lpszMethod; request_info.query_string=lpECB->lpszQueryString; - if(lpECB->lpszQueryString && *lpECB->lpszQueryString) { - char *reconstructed_uri=new(PointerFreeGC) char[ - strlen(lpECB->lpszPathInfo)+1/*'?'*/+ - strlen(lpECB->lpszQueryString)+1/*0*/]; - strcpy(reconstructed_uri, lpECB->lpszPathInfo); - strcat(reconstructed_uri, "?"); - strcat(reconstructed_uri, lpECB->lpszQueryString); - request_info.uri=reconstructed_uri; - } else - request_info.uri=lpECB->lpszPathInfo; - + request_info.uri=lpECB->lpszQueryString && *lpECB->lpszQueryString ? pa_strcat(lpECB->lpszPathInfo, "?", lpECB->lpszQueryString) : lpECB->lpszPathInfo; request_info.content_type=lpECB->lpszContentType; request_info.content_length=lpECB->cbTotalBytes; request_info.cookie=SAPI::Env::get(SAPI_info, "HTTP_COOKIE"); request_info.mail_received=false; // prepare to process request - Request request(SAPI_info, - request_info, - String::Language(String::L_HTML|String::L_OPTIMIZE_BIT)); + Request request(SAPI_info, request_info, String::Language(String::L_HTML|String::L_OPTIMIZE_BIT)); // beside by binary static char beside_binary_path[MAX_STRING]; strncpy(beside_binary_path, argv0, MAX_STRING-1); beside_binary_path[MAX_STRING-1]=0; // filespec of my binary - if(!( - rsplit(beside_binary_path, '/') || - rsplit(beside_binary_path, '\\'))) { // strip filename + if(!(rsplit(beside_binary_path, '/') || rsplit(beside_binary_path, '\\'))) { // strip filename // no path, just filename beside_binary_path[0]='.'; beside_binary_path[1]=0; - } + } char config_filespec[MAX_STRING]; - snprintf(config_filespec, MAX_STRING, - "%s/%s", - beside_binary_path, AUTO_FILE_NAME); - bool fail_on_config_read_problem=entry_exists(config_filespec); + snprintf(config_filespec, MAX_STRING, "%s/%s", beside_binary_path, AUTO_FILE_NAME); // process the request - request.core( - config_filespec, fail_on_config_read_problem, // /path/to/first/auto.p - header_only); + request.core(entry_exists(config_filespec) ? config_filespec : NULL, header_only); } #ifdef PA_SUPPRESS_SYSTEM_EXCEPTION