mirror of
https://github.com/git/git.git
synced 2024-06-15 08:46:26 +02:00
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>
This commit is contained in:
parent
8c8e978f57
commit
5053313562
10
urlmatch.c
10
urlmatch.c
|
@ -42,12 +42,12 @@ static int append_normalized_escapes(struct strbuf *buf,
|
||||||
|
|
||||||
from_len--;
|
from_len--;
|
||||||
if (ch == '%') {
|
if (ch == '%') {
|
||||||
if (from_len < 2 ||
|
if (from_len < 2)
|
||||||
!isxdigit(from[0]) ||
|
|
||||||
!isxdigit(from[1]))
|
|
||||||
return 0;
|
return 0;
|
||||||
ch = hexval(*from++) << 4;
|
ch = hex2chr(from);
|
||||||
ch |= hexval(*from++);
|
if (ch < 0)
|
||||||
|
return 0;
|
||||||
|
from += 2;
|
||||||
from_len -= 2;
|
from_len -= 2;
|
||||||
was_esc = 1;
|
was_esc = 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue