cvs: php4(PHP_4_3) /sapi/cgi cgi_main.c
| From: | Shane Caraveo | Date: | Mon, 19 May 2003 03:40:53 +0000 |
| Subject: | cvs: php4(PHP_4_3) /sapi/cgi cgi_main.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-21063@lists.php.net to get a copy of this message | ||
shane Sun May 18 23:40:53 2003 EDT
Modified files: (Branch: PHP_4_3)
/php4/sapi/cgi cgi_main.c
Log:
MFH
bugfix #13757 - passing query string on command line when run from shell
Index: php4/sapi/cgi/cgi_main.c
diff -u php4/sapi/cgi/cgi_main.c:1.190.2.26 php4/sapi/cgi/cgi_main.c:1.190.2.27
--- php4/sapi/cgi/cgi_main.c:1.190.2.26 Sat May 17 14:55:23 2003
+++ php4/sapi/cgi/cgi_main.c Sun May 18 23:40:53 2003
@@ -20,7 +20,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: cgi_main.c,v 1.190.2.26 2003/05/17 18:55:23 moriyoshi Exp $ */
+/* $Id: cgi_main.c,v 1.190.2.27 2003/05/19 03:40:53 shane Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -1374,45 +1374,45 @@
}
}
+ 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 */