From 92dfadb1e05dc11f5b4b93b68f06a545192b06ea Mon Sep 17 00:00:00 2001 From: Shane Caraveo Date: Mon, 19 May 2003 06:46:19 +0000 Subject: [PATCH] continuation on bugfix #13757 make argv/argc *and* query_string work correctly when running cgi in shell --- sapi/cgi/cgi_main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 3125a46f2b..d8503d1c07 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -1320,6 +1320,9 @@ consult the installation file that came with this distribution, or visit \n\ case 'f': /* parse file */ script_file = estrdup(optarg); no_headers = 1; + /* arguments after the file are considered script args */ + SG(request_info).argc = argc - (optind-1); + SG(request_info).argv = &argv[optind-1]; break; case 'g': /* define global variables on command line */ @@ -1415,6 +1418,9 @@ consult the installation file that came with this distribution, or visit \n\ } if (!SG(request_info).path_translated && argc > optind) { + /* arguments after the file are considered script args */ + SG(request_info).argc = argc - optind; + SG(request_info).argv = &argv[optind]; /* file is on command line, but not in -f opt */ SG(request_info).path_translated = estrdup(argv[optind++]); } @@ -1428,7 +1434,7 @@ consult the installation file that came with this distribution, or visit \n\ test.php "v1=test&v2=hello world!" test.php v1=test "v2=hello world!" */ - if (!SG(request_info).query_string) { + if (!SG(request_info).query_string && argc > optind) { len = 0; for (i = optind; i < argc; i++) { len += strlen(argv[i]) + 1; -- 2.40.0