--- parser3/src/targets/cgi/parser3.C 2001/04/11 08:13:41 1.63 +++ parser3/src/targets/cgi/parser3.C 2001/04/23 10:31:56 1.68 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: parser3.C,v 1.63 2001/04/11 08:13:41 paf Exp $ + $Id: parser3.C,v 1.68 2001/04/23 10:31:56 paf Exp $ */ #include "pa_config_includes.h" @@ -14,17 +14,12 @@ # include #endif -#include -#include -#include -#include -#include - #include "pa_sapi.h" #include "pa_common.h" #include "pa_globals.h" #include "pa_request.h" #include "pa_socks.h" +#include "pa_version.h" /// IIS refuses to read bigger chunks const size_t READ_POST_CHUNK_SIZE=0x400*0x400; // 1M @@ -152,7 +147,7 @@ int main(int argc, char *argv[]) { if(!cgi) { if(argc<2) { printf("Usage: %s \n", argv0?argv0:"parser3"); - exit(1); + return 1; } } @@ -178,7 +173,7 @@ int main(int argc, char *argv[]) { if(!filespec_to_process) PTHROW(0, 0, 0, - "no file to process"); + "Parser/%s", PARSER_VERSION); // Request info Request::Info request_info; @@ -206,7 +201,7 @@ int main(int argc, char *argv[]) { request_info.method=request_method; const char *query_string=SAPI::get_env(pool, "QUERY_STRING"); request_info.query_string=query_string; - if(cgi) + if(cgi) { if(const char *env_request_uri=SAPI::get_env(pool, "REQUEST_URI")) request_info.uri=env_request_uri; else if(const char *path_info=SAPI::get_env(pool, "PATH_INFO")) @@ -224,7 +219,14 @@ int main(int argc, char *argv[]) { PTHROW(0, 0, 0, "CGI: no PATH_INFO defined(in reinventing REQUEST_URI)"); - else + + const char *script_name=SAPI::get_env(pool, "SCRIPT_NAME"); + if(script_name && + strncmp(request_info.uri,script_name, strlen(script_name))==0) + PTHROW(0, 0, + 0, + "CGI: illegal call"); + } else request_info.uri=0; request_info.content_type=SAPI::get_env(pool, "CONTENT_TYPE"); @@ -236,7 +238,7 @@ int main(int argc, char *argv[]) { // prepare to process request Request request(pool, request_info, - 1||cgi ? String::UL_HTML_TYPO : String::UL_AS_IS + cgi ? String::UL_HTML_TYPO : String::UL_AS_IS ); // some root-controlled location @@ -246,7 +248,7 @@ int main(int argc, char *argv[]) { GetWindowsDirectory(root_auto_path, MAX_STRING); #else // ~nobody todo: figure out a better place - char *root_auto_path=SAPI::get_env(pool, "HOME"); + const char *root_auto_path=SAPI::get_env(pool, "HOME"); #endif // beside by binary