From dc6ba44ea66c471305908a8053d7de56d705e499 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Sat, 28 Oct 2017 00:03:18 +0200 Subject: [SERVER] Add function to parse x-www-form-urlencoded strings Use it to properly parse RPC queries. Will also come in handy when parsing POST body for calls that actually trigger any actions in the server (reload, alt-servers, ...) --- src/server/urldecode.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/server/urldecode.h (limited to 'src/server/urldecode.h') diff --git a/src/server/urldecode.h b/src/server/urldecode.h new file mode 100644 index 0000000..e27f8f8 --- /dev/null +++ b/src/server/urldecode.h @@ -0,0 +1,19 @@ +#ifndef _URLENCODE_H_ +#define _URLENCODE_H_ + +#include "picohttpparser/picohttpparser.h" + +struct field { + struct string name; + struct string value; +}; + +/** + * decode given x-form-urlencoded string. Breaks constness rules by + * casting the const char* s from str to char* and modifying it, then + * populating out with pointers into it, so make sure the memory + * is actually writable. + */ +void urldecode(struct string* str, struct field *out, size_t *out_num); + +#endif -- cgit v1.2.3-55-g7522