Querystring: fix decoding after invalid UTF-8
Previously, percent-decoding advanced past each encoded byte even when
the UTF-8 decoder left it unconsumed after reporting an invalid pending
sequence. For example, "%D8%41%42" decoded to "\ufffdB" instead of
"\ufffdAB". This affected querystring.parse() and unescape() in both
engines, and r.args in nginx.
Now njs_utf8_consume() reports whether the byte was consumed, so callers
can reread it before advancing the input, as the WHATWG UTF-8 decoder
requires. Plus signs are also passed through the decoder as spaces,
so they flush invalid pending sequences without losing or reordering
the replacement character.
The issue was introduced in
50ea0dbc (0.4.3), copied into QuickJS
r.args in
201b1276 (0.8.6) and into its querystring module in
f289dcb9
(0.8.10).