strbuf: fix urlencode format string on signed char
authorJulien Dusser <julien.dusser@free.fr>
Fri, 22 Dec 2017 17:24:37 +0000 (18:24 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 22 Dec 2017 21:43:19 +0000 (13:43 -0800)
Git credential fails with special char in password with

remote: Invalid username or password.
fatal: Authentication failed for

File ~/.git-credential contains badly urlencoded characters
%ffffffXX%ffffffYY instead of %XX%YY.

Add a cast to an unsigned char to fix urlencode use of %02x on a
char.

Signed-off-by: Julien Dusser <julien.dusser@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
strbuf.c
index 323c49ceb35cb053434248df869578e649ccadc0..4d5a9ce55166e801d75f60b19cc007a940bb4c9f 100644 (file)
--- a/strbuf.c
+++ b/strbuf.c
@@ -658,7 +658,7 @@ static void strbuf_add_urlencode(struct strbuf *sb, const char *s, size_t len,
                    (!reserved && is_rfc3986_reserved(ch)))
                        strbuf_addch(sb, ch);
                else
-                       strbuf_addf(sb, "%%%02x", ch);
+                       strbuf_addf(sb, "%%%02x", (unsigned char)ch);
        }
 }