When decoding a trigram, percent_decode() would correctly increment the input pointer by an extra two characters (three total) but would not decrement the input length by the same amount. This would result in a buffer over-read when decoding unterminated strings.
- Ensure that the output is always NUL-terminated.
- Always include the terminating NUL in the returned length.
- Allow out == NULL, allowing the caller to check how much space is required before allocating.
- Add man page.