From: "René Scharfe" <l.s.r@web.de>
To: Git List <git@vger.kernel.org>
Cc: "Kyle J. McKay" <mackyle@gmail.com>, Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] urlmatch: use hex2chr() in append_normalized_escapes()
Date: Sat, 8 Jul 2017 10:59:19 +0200 [thread overview]
Message-ID: <eb5e7bb5-d0a9-c8df-e89c-a2bd2430e8b6@web.de> (raw)
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>
---
urlmatch.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/urlmatch.c b/urlmatch.c
index 4bbde924e8..3e42bd7504 100644
--- a/urlmatch.c
+++ b/urlmatch.c
@@ -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;
}
--
2.13.2
next reply other threads:[~2017-07-08 8:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-08 8:59 René Scharfe [this message]
2017-07-08 14:28 ` [PATCH] urlmatch: use hex2chr() in append_normalized_escapes() Kyle J. McKay
2017-07-08 15:15 ` René Scharfe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=eb5e7bb5-d0a9-c8df-e89c-a2bd2430e8b6@web.de \
--to=l.s.r@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mackyle@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).