OpenPrinting / libcups

OpenPrinting CUPS Library Sources
https://openprinting.github.io/cups/cups3.html
Apache License 2.0
27 stars 15 forks source link

API for encoding and decode URL-encoded form data #49

Closed michaelrsweet closed 1 year ago

michaelrsweet commented 1 year ago

Add an API for encoding and decoding application/x-www-form-urlencoded form data. Proposed API:

// Decode URL-encoded form data, returning the number of variables and a pointer to a
// `cups_option_t` array of the variables. Use `cupsFreeOptions` to return memory.
extern size_t cupsFormDecode(const char *data, cups_option_t **vars) _CUPS_PUBLIC;

// Encode options as URL-encoded form data, returning an allocated string. Use `free`
// to return memory.
extern char *cupsFormEncode(size_t num_vars, cups_option_t *vars) _CUPS_PUBLIC;
michaelrsweet commented 1 year ago

[master 2eced324f] Initial implementation of cupsForm APIs (Issue #49)

Still need to finish the unit tests.

michaelrsweet commented 1 year ago

[master 9a3855ed0] Implement unit tests.

W3C forms specification defining (poorly) the application/x-www-form-urlencoded MIME media type. Unlike URLs, anything not a letter or digit needs to be percent encoded (which turned up with the unit tests...)