This file is indexed.

/usr/share/doc/libbobcat2-dev/man/cgi.3.html is in libbobcat-dev 2.20.01-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
<html><head>
<title>FBB::CGI</title>
<link rev="made" href="mailto:Frank B. Brokken: f.b.brokken@rug.nl">
</head>
<body text="#27408B" bgcolor="#FFFAF0">
<hr>
<h1>FBB::CGI</h1>
<h2>libbobcat1-dev_2.20.01-x.tar.gz</h2>
<h2>2005-2011</h2>

<html><head>
<link rev="made" href="mailto:Frank B. Brokken: f.b.brokken@rug.nl">
</head>
<body text="#27408B" bgcolor="#FFFAF0">
<hr>
<h1></h1>

<html><head>
<title>FBB::CGI(3bobcat)</title>
<link rev="made" href="mailto:Frank B. Brokken: f.b.brokken@rug.nl">
</head>
<body text="#27408B" bgcolor="#FFFAF0">
<hr>
<h1>FBB::CGI(3bobcat)</h1>
<h2>libbobcat1-dev_2.20.01-x.tar.gz CGI interface</h2>
<h2>2005-2011</h2>


<p>
<h2>NAME</h2>FBB::CGI - handles GET and POST submitted form data
<p>
<h2>SYNOPSIS</h2>
    <strong>#include &lt;bobcat/cgi&gt;</strong><br>
    Linking option: <em>-lbobcat</em> 
<p>
<h2>DESCRIPTION</h2>
<p>
The class <em>CGI</em> offers an interface to data submitted by web-forms. The
data is sent to a script handling the data using a <em>&lt;form
action="/path/to/form/script"&gt;</em> stanza. Very often this is indeed a script,
like a Perl script, but there is no need to use a scripting language. The
class <em>CGI</em> allows <strong>C++</strong> programmers to process the form by an executable
usually resulting in faster processing and in construction time benefits
from the type safety offered by <strong>C++</strong>. The class <em>CGI</em> handles data
submitted using the <em>GET</em> method as well as data submitted using the
<em>POST</em> method automatically.
<p>
By default the class's constructor writes the customary <em>Content-type</em>
header lines to the standard output stream. Additional (html) output of a
reply page must be provided by other code. Therefore, a program processing an
uploaded form will have an organization comparable to the following basic
setup:
        <pre>

    // assume includes and namespace std/FBB were defined
    int main()
    {
        CGI cgi;
        cout &lt;&lt; "&lt;html&gt;&lt;body&gt;\n";
        if (parametersOK(cgi))
        {
            process(cgi);     
            generateReplyPage();
        }
        else
            generateErrorPage();
        cout &lt;&lt; "&lt;/body&gt;&lt;/html&gt;\n;
    }
        
</pre>

<p>
When errors in the received form-data are detected an error message is
written to the standard output stream and an <em>FBB::Errno</em> exception is
thrown.
<p>
<h2>NAMESPACE</h2>
    <strong>FBB</strong><br>
    All constructors, members, operators and manipulators, mentioned in this
man-page, are defined in the namespace <strong>FBB</strong>.
<p>
<h2>INHERITS FROM</h2>
    -
<p>
<h2>TYPEDEF</h2>
    <ul>
    <li> <strong>CGI::MapStringVector</strong>:<br> 
       A shorthand for <em>std::unordered_map&lt;std::string, 
        std::vector&lt;std::string&gt; &gt;</em>,
        which is the data type in which form-variables are stored. 
    </ul>
<p>
<h2>ENUMERATIONS</h2>
    The <em>CGI::Method</em> enumeration specifies values indicating the way the
        form's data were submitted:
    <ul>
    <li> <strong>CGI::UNDETERMINED</strong>:<br>
       Used internally indicating that the form's method was neither <em>GET</em>
        nor <em>POST</em>.
    <li> <strong>CGI::GET</strong>:<br>
       Indicates that the <em>GET</em> method was used when submitting the form's
        data;
    <li> <strong>CGI::POST</strong>:<br>
       Indicates that the <em>POST</em> method was used when submitting the form's
        data.
    </ul>
<p>
The <em>CGI::Create</em> enumeration is used to request or suppress creation of
        the directory to contain any file uploaded by a form:
    <ul>
    <li> <strong>CGI::DONT_CREATE_PATH</strong>:<br>
       When uploading files, the destination directory must exist;
    <li> <strong>CGI::CREATE_PATH</strong>:<br>
       When uploading files, the destination directory will be created.
    </ul>
<p>
<h2>CONSTRUCTORS</h2>
    <ul>
    <li> <strong>CGI(bool defaultEscape = true, 
            char const *header = "Content-type: text/html", 
            std::ostream &amp;out = std::cout)</strong>:<br>
        The default constructor writes the standard content type header to the
standard output stream and will use <em>std::cout</em> for output. Specifying <em>0</em>
as header suppresses outputting the <em>Content-type</em> line. Otherwise the
content type line is also followed by two <em>\r\n</em> character combinations. By
default all characters in retrieved form-variables are escaped. The overloaded
insertion operators (see below) can be used to modify the default set of
characters which will be escaped. The backslash is the escape character. It
will be used unescaped only if the <em>defaultEscape</em> value is specified as
<em>false</em> and no insertions were performed.
    </ul>
    The copy and move constructors are available.
<p>
<h2>OERLOADED OPERATORS</h2>
<p>
<strong>Note:</strong> the following three insertion operators defining sets of
characters that should be escaped can only be used until the first time one of
the <em>param(), begin()</em> or <em>end()</em> members is called. Once one of these
latter three members has been called the set of characters to be escaped is
fixed and attempts to modify them will fail silently.
<p>
<ul>
    <li> <strong>CGI &amp;operator&lt;&lt;(std::string const &amp;accept)</strong>:<br>
       This member's actions are suppressed once <em>param(), begin()</em> or
        <em>end()</em> (see below) has been called.
<p>
The insertion operator can be used to fine-tune the set of characters
        that will be shown escaped in strings returned by <em>param()</em> (see
        below). Depending on the value of the constructor's <em>defaultEscape</em>
        parameter characters inserted into the <em>CGI</em> object will or will not
        be escaped by a backslash. If the constructor's <em>defaultEscape</em>
        parameter was specified as <em>true</em> then the insertion operator will
        define a set of characters that will <em>not</em> be escaped. If
        <em>defaultEscape</em> was specified as <em>false</em> then the insertion
        operator will define a set of characters that <em>will</em> be
        escaped. Once an insertion operator has been used the backlash itself
        will always be escaped and a request to use it unescaped is silently
        ignored. The <em>accept</em> string can be specified as a regular
        expression character set without specifying the surrounding square
        brackets. E.g., an insertion like <em>cgi &lt;&lt; "-a-z0-9"</em> will accept the
        dash, lower case letters and the digits. Individual characters,
        character ranges using the dash and all standard character classes
        (<em>[:alnum:], [:alpha:], [:cntrl:], [:digit:], [:graph:], [:lower:],
        [:print:], [:punct:], [:space:], [:upper:]</em>, and <em>[:xdigit:]</em>) can be
        used to specify a set of characters. In addition to these standard
        character classes the class <em>[:cgi:]</em> is available representing the
        set <em>" ' ` ;</em> and <em>\</em>.  Note that standard character classes
        <em>do</em> require you to specify square brackets. When a series of
        insertions are performed then the union of the sets defined by these
        insertions are used. <strong>Note</strong>: using unescaped single quotes, the
        double quotes, backtick characters and semicolons in CGI-programs
        might be risky and is not advised.
    <li> <strong>CGI &amp;operator&lt;&lt;(int c)</strong>:<br>
       This member's actions are suppressed once <em>param(), begin()</em> or
        <em>end()</em> (see below) has been called.
<p>
This insertion operator is used to change the default escape handling
        of a single character <em>c</em>. The <em>int</em> parameter is cast internally
        to a <em>char</em>.
    <li> <strong>CGI &amp;operator&lt;&lt;(std::pair&lt;char, char&gt; range)</strong>:<br>
       This member's actions are suppressed once <em>param(), begin()</em> or
        <em>end()</em> (see below) has been called.
<p>
This insertion operator can be used to change the default escape
        handling of a range of characters. The pair's second character must be
        equal to or exceed the position of the pair's first character in the
        ASCII collating sequence or the member will have no effect.
    <li> <strong>std::ostream &amp;std::operator&lt;&lt;(std::ostream &amp;out, CGI const &amp;cgi)</strong>:<br>
       <em>CGI</em> objects can be inserted into <em>ostreams</em> to display the
        characters that will appear escaped in strings returned by the 
        <em>param()</em> member function. Each character for which <em>isprint()</em>
        returns <em>true</em> will be displayed as character, surrounded by single
        quotes. For all other characters their ASCII values are displayed.
        Each character is displayed on a line by itself.
    <li> <strong>char const *operator[](std::string const &amp;key) const</strong>:<br>
        The index operator returns the value of the environment variable
        specified as the index. An empty string is returned if the variable
        specified at <em>key</em> is not defined.
    </ul>
<p>
The copy and move assignment operators are available. 
<p>
<h2>MEMBER FUNCTIONS</h2>
    <ul>
    <li> <strong>CGI::MapStringVector::const_iterator begin() const</strong>:<br>
       Returns the begin iterator of the form's parameter map. Iterator values
        unequal <em>end()</em> (see below) point to a pair of values, the first of
        which is the name of a field defined by the form, the second is a
        vector of strings containing the field's value(s). See also the
        description of the <em>param()</em> member below.
<p>
<li> <strong>CGI::MapStringVector::const_iterator end() const</strong>:<br>
       Returns the end iterator of the form's parameter map.
<p>
<li> <strong>unsigned long long maxUploadSize() const</strong>:<br>
       Returns the current maximum file upload size in bytes.
<p>
<li> <strong>CGI::Method method() const</strong>:<br> 
       Returns the method used when submitting the form as either <em>CGI::GET</em>
        or <em>CGI::POST</em>.
<p>
<li> <strong>std::vector&lt;std::string&gt; const &amp;param(std::string const &amp;variable)
        const</strong>:<br>
       Returns the value of the form-variable specified by the function's
        argument. An empty vector is returned if the variable was not provided
        by the form's data. If the same variable was specified multiple times
        or if its value extends over multiple lines (only with
        <em>multipart/form-data</em>) then the vector will contain multiple
        strings. With <em>GET</em> and <em>POST</em> methods not using
        <em>multipart/form-data</em> input fields extending over multiple lines are
        stored in one string, using <em>\r\n</em> combinations between those
        lines.
       <br> When files are uploaded the vectors contain sets of four
        strings. The first string provides the path nme of the uploaded file;
        the second string provides the file name specified in the form itself
        (so it is the name of the file at the remote location); the third
        string shows the content type specified by the remote browser (e.g.,
        <em>application/octet-stream</em>), the fourth string contains <em>OK</em> if
        the file was successfully uploaded and <em>truncated</em> if the file was
        truncated. Existing files will not be overwritten. When uploading a
        file a usable filename must be found within 100 trials.
<p>
<li> <strong>std::string const &amp;query() const</strong>:<br> 
       Returns the query-string submitted with <em>CGI::GET</em> or <em>CGI::POST</em>
        forms (if the <em>POST</em>ed form specified
        <em>ENCTYPE="multipart/form-data"</em> the query string is empty). 
<p>
<li> <strong>report()</strong>:<br>
        The <em>report</em> member silently returns if no errors were encountered
        while processing form-data. Otherwise, the <em>html</em> file generated by
        the <em>CGI</em> program will display a line starting with <em>FBB::CGI</em>,
        followed by the status report. 
<p>
The following status report messages are presently defined:
        <ul> 
       <li> <em>Content-Disposition not recognized in:</em>, which is followed by the
        line where the <em>Content-Disposition</em> was expected. This may occur
        when processing <em>multipart/form</em> data.
       <li> <em>Invalid multipart/form-data</em>. This message can be generated when
        readling lines while processing <em>multipart/form</em> data.
       <li> <em>GET/POST REQUEST_METHOD not found</em>. This message is shown if the
        program couldn't find the form's <em>REQUEST_METHOD</em> type (i.e.,
        <em>GET</em> or <em>POST</em>).
       <li> <em>Invalid CONTENT_LENGHT in POSTed form</em>. This message is shown if
        the content-length header has an incorrect value.
       <li> <em>Content-Type not found for file-field</em>, followed by the file's
        field name. This message is shown if no <em>Content-Type</em> specification
        was found in an uploaded form.
       <li> <em>Can't open a file to write an uploaded file</em>. This message
        indicates that the CGI program was unable to open a file to write an
        uploaded file to. This can be caused by an overfull disk or partition
        or by incorrect write-permissions.
       <li> <em>multipart/form-data: no end-boundary found</em>. This message is shown
        if the end-boundary was missing in a <em>multipart/form-data</em> form.
        </ul>
<p>
<li> <strong>void setFileDestination(std::string const &amp;path, 
                                std::string const &amp;prefix = "",
                                Create create = CREATE_PATH)</strong>:<br>
       This member is used to specify the path and prefix of uploaded
        files. Uploaded files will be stored at <em>path/prefixNr</em> where <em>Nr</em>
        is an internally used number starting at one. When <em>CREATE_PATH</em> is
        specified <em>path</em> must be available or the <strong>CGI</strong> object must be
        able to create the path. If <em>DONT_CREATE_PATH</em> is specified the
        specified path must be available. If not, an <em>FBB::Errno</em> exception
        will be thrown.
<p>
<li> <strong>void setMaxUploadSize(size_t maxSize, int unit = 'M')</strong>:<br>
       This member can be used to change the maximum size of uploaded
        files. Its default value is 100Mb. The <em>unit</em> can be one of <em>b</em>
        (bytes, the default), <em>K</em> (Kbytes), <em>M</em> (Mbytes) or <em>G</em>
        (Gbytes). Unit-specifiers are interpreted case insensitively. File
        uploads will continue until the maximum upload size is exceeded,
        followed by discarding any remainder.
    </ul>
    The first time one of the <em>param(), begin()</em> or <em>end()</em> members is
called these members may detect errors in the the received form data. If so,
an error message is written to the standard output stream and an
<em>FBB::Errno</em> exception will be thrown.
<p>
<h2>STATIC MEMBERS</h2>
    <ul>
    <li> <strong>std::string dos2unix(std::string const &amp;text)</strong>:<br>
        This member converts all <em>\r\n</em> character combinations in <em>text</em>
        into plain <em>\n</em> characters, returning the converted text.
<p>
<li> <strong>std::string unPercent(std::string const &amp;text)</strong>:<br> This member converts
        all <em>%xx</em> encoded characters into their corresponding ASCII
        values. Also, <em>+</em> characters are converted to single blank
        spaces. The converted string is returned.
    </ul>    
<p>
<h2>EXAMPLE</h2>
    <pre>
#include "main.ih"

void outstr(string const &amp;str)
{
    cout &lt;&lt; CGI::dos2unix(str) &lt;&lt; "\n"
            "    ";
}

void showParam(CGI::MapStringVector::value_type const &amp;mapValue)
{
    cout &lt;&lt; "Param: " &lt;&lt; mapValue.first &lt;&lt; "\n"
            "    ";

    FBB::for_each(mapValue.second.begin(), mapValue.second.end(), outstr);
    cout &lt;&lt; endl;
}

int main(int argc, char **argv)
try
{
    Arg &amp;arg = Arg::initialize("evhm:", argc, argv);

    arg.versionHelp(usage, version, 2);

    ifstream in(arg[0]);
    string line;
    while (getline(in, line))
    {
        size_t pos = line.find('=');
        if (pos == string::npos)
            continue;
        if (setenv(line.substr(0, pos).c_str(), 
               line.substr(pos + 1).c_str(), true) == 0)
        {
            if (arg.option('e'))
                cout &lt;&lt; line.substr(0, pos).c_str() &lt;&lt; '=' &lt;&lt;
                       line.substr(pos + 1).c_str() &lt;&lt; endl;
        }
        else
            cout &lt;&lt; "FAILED: setenv " &lt;&lt; line &lt;&lt; endl;
    }

    CGI cgi(false);             // by default no escapes

    cgi &lt;&lt; arg[1];

    if (arg.option(&amp;line, 'm'))
        cgi.setMaxUploadSize(A2x(line), *line.rbegin());

    cout &lt;&lt; "Max upload size (b): " &lt;&lt; cgi.maxUploadSize() &lt;&lt; endl;

    CGI::Method method = cgi.method();

    cout &lt;&lt; "To escape:\n" &lt;&lt; 
            cgi &lt;&lt; "\n"
            "Method: " &lt;&lt; (method == CGI::GET ? "GET" : "POST") &lt;&lt;
            endl;

    cout &lt;&lt; "Query string: " &lt;&lt; cgi.query() &lt;&lt; endl;

    cgi.param("submit");

    FBB::for_each(cgi.begin(), cgi.end(), &amp;showParam);

    cout &lt;&lt; "END OF PROGRAM\n";

    return 0;
}
catch (Errno const &amp;err)
{
    cout &lt;&lt; err.why() &lt;&lt; endl;
    return 1;
}
catch (...)
{
    return 1;
}




</pre>

<p>
To test the program provide it, e.g., with the following file at its standard
input: 
<p>
<pre>
INFO=This is an abbreviated set of environment variables
SERVER_ADMIN=f.b.brokken@rug.nl
GATEWAY_INTERFACE=CGI/1.1
SERVER_PROTOCOL=HTTP/1.1
REQUEST_METHOD=GET
QUERY_STRING=hidden=hidval&amp;submit=Submit+%20Query
</pre>

<p>
<h2>FILES</h2>
    <em>bobcat/cgi</em> - defines the class interface
<p>
<h2>SEE ALSO</h2>
    <strong>bobcat</strong>(7)
<p>
<h2>BUGS</h2>
    None Reported.
<p>

<h2>DISTRIBUTION FILES</h2>
    <ul>
    <li> <em>bobcat_2.20.01-x.dsc</em>: detached signature;
    <li> <em>bobcat_2.20.01-x.tar.gz</em>: source archive;
    <li> <em>bobcat_2.20.01-x_i386.changes</em>: change log;
    <li> <em>libbobcat1_2.20.01-x_*.deb</em>: debian package holding the
            libraries;
    <li> <em>libbobcat1-dev_2.20.01-x_*.deb</em>: debian package holding the
            libraries, headers and manual pages;
    <li> <em>http://sourceforge.net/projects/bobcat</em>: public archive location;
    </ul>
<p>
<h2>BOBCAT</h2>
    Bobcat is an acronym of `Brokken's Own Base Classes And Templates'.
<p>
<h2>COPYRIGHT</h2>
    This is free software, distributed under the terms of the 
    GNU General Public License (GPL).
<p>
<h2>AUTHOR</h2>
    Frank B. Brokken (<strong>f.b.brokken@rug.nl</strong>).
<p>