diff options
author | René Scharfe <l.s.r@web.de> | 2017-07-08 08:59:19 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-07-09 16:43:01 (GMT) |
commit | 50533135622a80b0326c7e93067e136072bef5eb (patch) | |
tree | 0e6c773ec82340927d3479481523a47a48abd939 /urlmatch.c | |
parent | 8c8e978f5719c6a58fb998742207bf907f963143 (diff) | |
download | git-50533135622a80b0326c7e93067e136072bef5eb.zip git-50533135622a80b0326c7e93067e136072bef5eb.tar.gz git-50533135622a80b0326c7e93067e136072bef5eb.tar.bz2 |
urlmatch: use hex2chr() in append_normalized_escapes()
Simplify the code by using hex2chr() to convert and check for invalid
characters at the same time instead of doing that sequentially with
one table lookup for each.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'urlmatch.c')
-rw-r--r-- | urlmatch.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -42,12 +42,12 @@ static int append_normalized_escapes(struct strbuf *buf, from_len--; if (ch == '%') { - if (from_len < 2 || - !isxdigit(from[0]) || - !isxdigit(from[1])) + if (from_len < 2) return 0; - ch = hexval(*from++) << 4; - ch |= hexval(*from++); + ch = hex2chr(from); + if (ch < 0) + return 0; + from += 2; from_len -= 2; was_esc = 1; } |