From: Shane Caraveo Date: Mon, 19 May 2003 06:46:50 +0000 (+0000) Subject: MFH X-Git-Tag: BEFORE_FD_REVERT~34 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=331f905e8aeac5bdd88d456500f3b90fe9dadc68;p=php MFH continuation on bugfix #13757 make argv/argc *and* query_string work correctly when running cgi in shell --- diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 24e6027d89..aebbe90f8f 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -1279,6 +1279,9 @@ consult the installation file that came with this distribution, or visit \n\ case 'f': /* parse file */ script_file = estrdup(ap_php_optarg); no_headers = 1; + /* arguments after the file are considered script args */ + SG(request_info).argc = argc - (ap_php_optind-1); + SG(request_info).argv = &argv[ap_php_optind-1]; break; case 'g': /* define global variables on command line */ @@ -1385,6 +1388,9 @@ consult the installation file that came with this distribution, or visit \n\ } if (!SG(request_info).path_translated && argc > ap_php_optind) { + /* arguments after the file are considered script args */ + SG(request_info).argc = argc - ap_php_optind; + SG(request_info).argv = &argv[ap_php_optind]; /* file is on command line, but not in -f opt */ SG(request_info).path_translated = estrdup(argv[ap_php_optind++]); } @@ -1398,7 +1404,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 > ap_php_optind) { len = 0; for (i = ap_php_optind; i < argc; i++) { len += strlen(argv[i]) + 1;