diff options
author | Andrei Belov <defan@nginx.com> | 2020-05-28 18:13:06 +0300 |
---|---|---|
committer | Andrei Belov <defan@nginx.com> | 2020-05-28 18:13:06 +0300 |
commit | 733c14e991d6b2d5bdae5202ae9f090d022bc956 (patch) | |
tree | 120562db5d30e5f4f51d001397f765f5cebab999 /src/nxt_string.c | |
parent | 6a8d4571d7fc89a951b4da80c39a93fcaa634406 (diff) | |
parent | 9d8e476c4e3695019b0a1fe3696d3411a8393de6 (diff) | |
download | unit-733c14e991d6b2d5bdae5202ae9f090d022bc956.tar.gz unit-733c14e991d6b2d5bdae5202ae9f090d022bc956.tar.bz2 |
Merged with the default branch.
Diffstat (limited to '')
-rw-r--r-- | src/nxt_string.c | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/src/nxt_string.c b/src/nxt_string.c index 54f96abc..ab568990 100644 --- a/src/nxt_string.c +++ b/src/nxt_string.c @@ -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) { |