Empty command line parameters are ignored
Brought to you by:
samh
SpeedyCGI 2.22 doesn't pass empty command line parameters
along to the Perl interpreter (I tried with Perl 5.8.0 and Perl 5.8.4):
> echo 'print "\@ARGV = (".join(",", @ARGV).")\n";' >param.pl
> perl param.pl a b '' c
@ARGV = (a,b,,c)
> speedy param.pl a b '' c
@ARGV = (a,b,,c)
Logged In: YES
user_id=319826
Oups, I made a typo when posting the example. Correction:
> echo 'print "\@ARGV = (".join(",", @ARGV).")\n";' >param.
pl
> perl param.pl a b '' c
@ARGV = (a,b,,c)
> speedy param.pl a b '' c
@ARGV = (a,b,c)
Logged In: YES
user_id=858195
Hi,
this patch seems to fix the problem for me. Hope it helps.
I couldn't find a way to attach it, so here's a copy-paste.
It can also be
found at
http://www.helsinki.fi/~ntyni/speedy-empty-patch
Cheers,
--
Niko Tyni
ntyni@iki.fi
--- speedy_frontend.c 2005/10/04 11:46:15 1.1
+++ speedy_frontend.c 2005/10/04 11:47:52
@@ -535,7 +535,26 @@
ADD_STRING(b, s, l);
}
}
+ /* Terminate with zero-length string */
+ ADDCHAR(b, 0);
+}
+
+/* Copy a block of strings into the buffer, including empty
strings */
+static void add_strings_with_empty(register SpeedyBuf *b,
register const char * const * p)
+{
+ int l;
+ register const char *s;
+ /* Add strings in p array */
+ for (; (s = *p); ++p) {
+ if ((l = strlen(s))) {
+ ADD_STRING(b, s, l);
+ } else {
+ /* add a 1-byte long string containing just '\0' */
+ l = 1;
+ ADD_STRING(b, s, l);
+ }
+ }
/* Terminate with zero-length string */
ADDCHAR(b, 0);
}
@@ -560,7 +579,7 @@
/* Add env and argv */
add_strings(sb, envp);
- add_strings(sb, scr_argv+1);
+ add_strings_with_empty(sb, scr_argv+1);
/* Put script filename into buffer */
add_string(sb, script_fname, strlen(script_fname));