diff options
| author | Shane Caraveo <shane@php.net> | 2003-05-19 03:40:53 +0000 |
|---|---|---|
| committer | Shane Caraveo <shane@php.net> | 2003-05-19 03:40:53 +0000 |
| commit | 818412a4a9661b8d59308993911bcc7f48d34268 (patch) | |
| tree | a1d3359a8363531c6e8413c2f4f661c85708dddf /sapi/cgi/cgi_main.c | |
| parent | 45a703d3f16ec6b2a706d687be0dce1832620c55 (diff) | |
| download | php-git-818412a4a9661b8d59308993911bcc7f48d34268.tar.gz | |
MFH
bugfix #13757 - passing query string on command line when run from shell
Diffstat (limited to 'sapi/cgi/cgi_main.c')
| -rw-r--r-- | sapi/cgi/cgi_main.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 940a463cf4..24e6027d89 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -1374,46 +1374,46 @@ consult the installation file that came with this distribution, or visit \n\ } } + if (script_file) { + /* override path_translated if -f on command line */ + SG(request_info).path_translated = script_file; + } + + if (no_headers) { + SG(headers_sent) = 1; + SG(request_info).no_headers = 1; + } + + if (!SG(request_info).path_translated && argc > ap_php_optind) { + /* file is on command line, but not in -f opt */ + SG(request_info).path_translated = estrdup(argv[ap_php_optind++]); + } + + /* all remaining arguments are part of the query string + this section of code concatenates all remaining arguments + into a single string, seperating args with a & + this allows command lines like: + + test.php v1=test v2=hello+world! + test.php "v1=test&v2=hello world!" + test.php v1=test "v2=hello world!" + */ if (!SG(request_info).query_string) { len = 0; - if (script_file) { - len += strlen(script_file) + 1; - } for (i = ap_php_optind; i < argc; i++) { len += strlen(argv[i]) + 1; } s = malloc(len + 1); /* leak - but only for command line version, so ok */ *s = '\0'; /* we are pretending it came from the environment */ - if (script_file) { - strcpy(s, script_file); - if (ap_php_optind<argc) { - strcat(s, "+"); - } - } for (i = ap_php_optind, len = 0; i < argc; i++) { strcat(s, argv[i]); if (i < (argc - 1)) { - strcat(s, "+"); + strcat(s, "&"); } } SG(request_info).query_string = s; } - - if (script_file) { - /* override path_translated if -f on command line */ - SG(request_info).path_translated = script_file; - } - - if (no_headers) { - SG(headers_sent) = 1; - SG(request_info).no_headers = 1; - } - - if (!SG(request_info).path_translated && argc > ap_php_optind) { - /* file is on command line, but not in -f opt */ - SG(request_info).path_translated = estrdup(argv[ap_php_optind]); - } } /* end !cgi && !fastcgi */ /* |
