Handles HTML form submissions

Author: Adrián Pérez <aperez@igalia.com>
Copyright: 2008-2009 Igalia S.L.
License:GPL3

Abstract

Handles input in the formats provided by HTML forms. This includes submissions in the multipart/form-data and application/x-www-form-urlencoded encodings. This functionality is typically needed in CGI scripts.

Contents

form_urldecode

form_urldecode hash

Reads data in a line-by-line basis from standard input, performs URL-like decoding as defined in RFC 1945 and sends it decoded to standard output.

form_multipart_handle

form_multipart_handle directory

Decodes standard input in multipart/form-data encoding to multiple files in a directory. The directory will be laid out as follows, for a directory named output:

output/pack
File containing the unprocessed input, minus the marker present at the last line.
output/raw/*
Each file inside this directory is an unprocessed part of the input.
output/body/*
Each file inside this directory contains the bodies of the parts.
output/headers/*
Each file inside this directory contains the MIME headers of each part.

For example, the first part will be named 00 (double-zero), output/raw/00 would be the unprocessed part, output/body/00 its content body and output/headers/00 the corresponding MIME headers. Each part is decoded using the mime_decode function.

form_handle

form_handle hash [ tmpdir ]

Handles input if a HTML form, either from a POST or GET request. In both cases the query string will be stored in the hash table. When handling POST requests you may also want to provide a temporary directory tmpdir, otherwise /tmp will be always used. Data stored in hash can be accessed using the functions in the data/hash module.