/
cgidecode.man
120 lines (118 loc) · 4.05 KB
/
cgidecode.man
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
.TH cgidecode 1 "2015"
.SH cgidecode
.B cgidecode
\- decode url-encoded and multipart-encoded data
.SH SYNOPSIS
#ifdef REGEX
.B cgidecode [-V][-q][-D
directory
.B ][-r][-M
maxsize
.B ] [-C
suffix
.B ] [-e
encoding
.B ]
[varname-regex \.\.\.]
#else /* !REGEX */
.B cgidecode [-V][-q][-D
directory
.B ][-r][-M
maxsize
.B ] [-C
suffix
.B ] [-e
encoding
.B ]
[varname \.\.\.]
#endif /* !REGEX */
.SH DESCRIPTION
The cgidecode utility decodes url-encoded or multipart-encoded data provided to it on
stdin, and extracts from that data the name and value of any variable whose name
matches a variable name argument on the command line.
.PP
The arguments indicate variable names to be looked for in the data. Variable
names in the data that are not specified on the command line will not be seen, and are ignored.
.PP
If the data is URL-encoded, the name and value of each variable
in the input whose name matches one of the variable name arguments is output to stdout,
in the form
.B "varname=value"
.PP
If the data is multipart-encoded, the name of each variable
whose name matches one of the variable name arguments is output to stdout, followed by
a space, then any content-disposition parameters, if present, such as
.B filename="myfilename".
Finally, it also displays
.B contenttype="conttent/type"
(if present in the data for that variable). All these are output on a single line, separated by semicolons.
#ifdef REGEX
.PP
Variable name arguments are specified on the command line as POSIX regular expressions.
#endif /* REGEX */
.SH OPTIONS
.TP
.B \-e encoding
The type of encoding that
.B cgidecode
expects as input.
Encoding can be "url", "multipart", or "autodetect" (the default).
.TP
.B \-V
Display version information and exit.
.TP
.B \-q
Quiet mode. Do not output anything to stdout.
.TP
.B \-D directory
Create the specified directory. If the directory already exists, an error
is reported, unless the -r flag is used. For each matching variable name,
create a file in that directory whose name is the name of the variable,
and whose content is the value of the variable. If a variable appears
more than once, a subdirectory named after the variable is created, and
each value of that variable is written as a file in that subdirectory,
named "0", "1", "2", etc. in order of appearance.
.TP
.B \-r
Reuse the directory specified via -D, if it already exists. If it contains
files/subdirectories with names the same as variables seen by cgidecode,
cgidecode will behave as it does in the case where a variable is seen more
than once, as described in the description for -D above.
.TP
.B \-M maxsize
Specify the maximum size of input that will be read. Append "k" or "K" to
multiply by 1000, "m" or "M" by a million, and "g" or "G" by a billion.
If a desired variable is being read when the maxsize limit is reached, a
truncated value will be used. Any variables in the input beyond the
maxsize limit will be ignored.
.TP
.B \-C suffix
Suffix for a subdirectory in above directory to hold content-disposition
parameters and content-type, if any.
For example, if suffix is ".cdisp", and variable "myvariable" has a content-type, then that content-type
will be saved in a file called "directory/myvariable.cdisp/content-type"
or e.g. "directory/myvariable/1.cdisp/content-type" (in the case of multiple
instances of "myvariable").
Has no effect if directory is not specified.
Content-disposition parameters are applicable only to multipart-encoded data.
The suffix should be chosen so that forms will not have variable names
such that a matching variable name, with the suffix appended, will be the same
as another matching variable name in the form.
.SH EXAMPLE
.TP
.RS
.RE
cgidecode -e multipart -D mydir -C .cdisp myfile <form-data
.RS
echo Upload filename is: `cat mydir/myfile.cdisp/filename`
.RE
.RS
echo Upload filetype is: `cat mydir/myfile.cdisp/content-type`
.RE
.RS
echo Upload filesize is: `du -s mydir/myfile`
.RE
.SH IDIOSYNCRASIES
CRLF is mapped to LF in the UNIX fashion. Only content-disposition parameters mentioned in rfc2183 are recognized.
.SH AUTHOR
John DiMarco <jdd@cs.toronto.edu>