From a0f5f7509bb9040752fa61fe0fdb447608e22b1c Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Tue, 30 Sep 2025 23:50:33 +0200 Subject: Implement form interface This new interface allows library users to parse application/x-www-form-urlencoded data conveniently. --- examples/form/README.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 examples/form/README.md (limited to 'examples/form/README.md') diff --git a/examples/form/README.md b/examples/form/README.md new file mode 100644 index 0000000..6be1969 --- /dev/null +++ b/examples/form/README.md @@ -0,0 +1,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 +``` -- cgit v1.2.3