Router: decode uri and args.

This commit is contained in:
Axel Duch
2020-05-14 12:29:06 +02:00
parent 376d758dd7
commit ee1e248f4b
4 changed files with 381 additions and 60 deletions

View File

@@ -475,7 +475,7 @@ nxt_strvers_match(u_char *version, u_char *prefix, size_t length)
}
static const uint8_t nxt_hex2int[256]
const uint8_t nxt_hex2int[256]
nxt_aligned(32) =
{
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
@@ -551,6 +551,47 @@ nxt_decode_uri(u_char *dst, u_char *src, size_t length)
}
u_char *
nxt_decode_uri_plus(u_char *dst, u_char *src, size_t length)
{
u_char *end, ch;
uint8_t d0, d1;
nxt_prefetch(&nxt_hex2int['0']);
end = src + length;
while (src < end) {
ch = *src++;
switch (ch) {
case '%':
if (nxt_slow_path(end - src < 2)) {
return NULL;
}
d0 = nxt_hex2int[*src++];
d1 = nxt_hex2int[*src++];
if (nxt_slow_path((d0 | d1) >= 16)) {
return NULL;
}
ch = (d0 << 4) + d1;
break;
case '+':
ch = ' ';
break;
}
*dst++ = ch;
}
return dst;
}
uintptr_t
nxt_encode_uri(u_char *dst, u_char *src, size_t length)
{