Merge branch 'bc/wildcard-credential'

Update the parser used for credential.<URL>.<variable>
configuration, to handle <URL>s with '/' in them correctly.

* bc/wildcard-credential:
  credential: fix matching URLs with multiple levels in path
This commit is contained in:
Junio C Hamano
2020-05-05 14:54:26 -07:00
4 changed files with 58 additions and 6 deletions

View File

@ -479,15 +479,17 @@ void strbuf_addbuf_percentquote(struct strbuf *dst, const struct strbuf *src)
}
}
#define URL_UNSAFE_CHARS " <>\"%{}|\\^`:/?#[]@!$&'()*+,;="
#define URL_UNSAFE_CHARS " <>\"%{}|\\^`:?#[]@!$&'()*+,;="
void strbuf_add_percentencode(struct strbuf *dst, const char *src)
void strbuf_add_percentencode(struct strbuf *dst, const char *src, int flags)
{
size_t i, len = strlen(src);
for (i = 0; i < len; i++) {
unsigned char ch = src[i];
if (ch <= 0x1F || ch >= 0x7F || strchr(URL_UNSAFE_CHARS, ch))
if (ch <= 0x1F || ch >= 0x7F ||
(ch == '/' && (flags & STRBUF_ENCODE_SLASH)) ||
strchr(URL_UNSAFE_CHARS, ch))
strbuf_addf(dst, "%%%02X", (unsigned char)ch);
else
strbuf_addch(dst, ch);