blob: 6be19698cf5615f633e9078a7359e3c3e683565d (
plain) (
blame)
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
|
# HTML forms example
This example shows how to parse `application/x-www-form-urlencoded`-encoded
data using `libweb`s `form` API, using untrusted user input.
## How to build
If using `make(1)`, just run `make` from this directory.
If using CMake, examples are built by default when configuring the project
from [the top-level `CMakeLists.txt`](../../CMakeLists.txt).
## How to run
Run the executable with a `application/x-www-form-urlencoded`-encoded given
as its only argument.
For example:
```sh
$ ./form 'username=admin&password=mypassword'
```
Shall return:
```
key=username, value=admin, cnt=1
key=password, value=mypassword, cnt=2
```
An invalid string shall be reported to `stderr`:
```sh
$ ./form 'username=admin&thisisawrongvalue'
```
```
main: invalid user input: username=admin&thisisawrongvalue
```
|