summaryrefslogtreecommitdiffstats
path: root/strbuf.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2024-10-30 00:39:04 +0100
committerJohannes Schindelin <johannes.schindelin@gmx.de>2024-11-26 22:14:58 +0100
commit102e0e6daa920a811890a612578a7723335b1f77 (patch)
treec1f9189b3dbb65ee029f4d46ea18f78cd3384c2b /strbuf.c
parentGit 2.42.3 (diff)
parentGit 2.41.3 (diff)
downloadgit-102e0e6daa920a811890a612578a7723335b1f77.tar.xz
git-102e0e6daa920a811890a612578a7723335b1f77.zip
Sync with 2.41.3
* maint-2.41: Git 2.41.3 Git 2.40.4 credential: disallow Carriage Returns in the protocol by default credential: sanitize the user prompt credential_format(): also encode <host>[:<port>] t7300: work around platform-specific behaviour with long paths on MinGW compat/regex: fix argument order to calloc(3) mingw: drop bogus (and unneeded) declaration of `_pgmptr` ci: remove 'Upload failed tests' directories' step from linux32 jobs
Diffstat (limited to 'strbuf.c')
-rw-r--r--strbuf.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/strbuf.c b/strbuf.c
index 4c9ac6dc5e..0e5562450d 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -463,7 +463,9 @@ void strbuf_add_percentencode(struct strbuf *dst, const char *src, int flags)
unsigned char ch = src[i];
if (ch <= 0x1F || ch >= 0x7F ||
(ch == '/' && (flags & STRBUF_ENCODE_SLASH)) ||
- strchr(URL_UNSAFE_CHARS, ch))
+ ((flags & STRBUF_ENCODE_HOST_AND_PORT) ?
+ !isalnum(ch) && !strchr("-.:[]", ch) :
+ !!strchr(URL_UNSAFE_CHARS, ch)))
strbuf_addf(dst, "%%%02X", (unsigned char)ch);
else
strbuf_addch(dst, ch);