cgiparse
handles QUERY_STRING
environment
variable parsing for CGI scripts. It comes with W3C httpd
distributions 2.15 and newer.
If the QUERY_STRING
environment variable is not set, it
reads CONTENT_LENGTH
characters from its standard input.
296c296,297 < printf("QUERY_STRING='%s'; export QUERY_STRING\n", query_string) ; --- > printf("QUERY_STRING=%s; export QUERY_STRING\n" > , sh_escape(query_string)) ;
cgiparse -keywords
QUERY_STRING
as search keywords. Keywords
are decoded and written to standard output, one per line.
cgiparse -form
QUERY_STRING
as form request.
Outputs a string which, when eval
'ed by Bourne shell,
will set shell variables beginning with FORM_
appended with field name. Field values are the contents of
the variables.
cgiparse -value
fieldnameQUERY_STRING
as form request.
Prints only the value of field fieldname.
cgiparse -read
CONTENT_LENGTH
characters from
stdin
and write them to stdout.
cgiparse -init
QUERY_STRING
is not defined, read
stdin
and output a string that when
eval
'd by Bourne shell it will set
QUERY_STRING
to its correct value. This can be
used when the same script is used with both GET
and POST
method. Typical use in the beginning of
Bourne shell script:
eval `cgiparse -init`After this command the
QUERY_STRING
environment
variable will be set regardless of whether GET
or
POST
method was used. Therefore
cgiparse
may be called multiple times in the same
script (otherwise with POST
it could only be
called once because after that the stdin
would be
already read, and the next cgiparse
would hang).
-sep
separator-value
default is newline
-form
default is ", "
-prefix
prefix-form.
Specify the prefix to use when making up environment
variable names. Default is "FORM_".
-count
-keywords
outputs the number of keywords
-form
outputs the number of unique fields
(multiple values are counted as one)
-value
fieldname gives the number of
values of field fieldname (no such field is
zero, one field gives 1, one multiple 2, etc).
-
number , e.g. -2
-keywords
gives n'th keyword
-form
gives all the values of n'th
field
-value
fieldname gives n'th
of the multiple values of field fieldname
(first value is number 1).
-quiet
-k -f -v -r -i -s -p -c -q
0
Success
1
Illegal command line
2
Environment variables not set correctly
3
Failed to get requested information (no such
field, QUERY_STRING
contains
keywords when form field values requested,
etc).
QUERY_STRING
is already
set by the server.
Here $
is the Bourne shell prompt.
$ QUERY_STRING="is+2%2B2+really+four%3F" $ export QUERY_STRING $ cgiparse -keywords is 2+2 really four? $
$ QUERY_STRING="name1=value1&name2=Second+value%3F+That%27s right%21" $ export QUERY_STRING $ cgiparse -form FORM_name1='value1'; FORM_name2='Second value? That'\''s right!' $ eval `cgiparse -form` $ set ... FORM_name1=value1 FORM_name2=Second value? That's right! ... $
QUERY_STRING as in previous example. $ cgiparse -value name1 value1 $ cgiparse -value name2 Second value? That's right! $