Skip to content

Commit 4b732b9

Browse files
committed
helper-selector: fix quoting of trailing backslashes
In Git for Windows' 6d8684161ee9 (mingw: fix quoting of arguments, 2019-09-13), we fixed a bug where it would quote command-line arguments with trailing backslashes incorrectly when they needed to be quoted. While the helper-selector only quotes paths to files (which, by definition, cannot end in a backslash), we still should fix the `quote()` function, just in case that we will want to use it on parameters other than file paths. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent ca50867 commit 4b732b9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

git-extra/git-credential-helper-selector.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ static LPWSTR quote(LPWSTR string)
291291
while (end[1] == L'\\')
292292
end++;
293293
len += end - p;
294-
if (end[1] == L'"')
294+
if (end[1] == L'"' ||
295+
(needs_quotes && end[1] == L'\0'))
295296
len += end - p + 1;
296297
p = end;
297298
}
@@ -313,7 +314,7 @@ static LPWSTR quote(LPWSTR string)
313314
memcpy(q, p, (end - p) * sizeof(WCHAR));
314315
q += end - p;
315316
}
316-
if (end[1] == L'"') {
317+
if (end[1] == L'"' || end[1] == L'\0') {
317318
memcpy(q, p, (end - p + 1) * sizeof(WCHAR));
318319
q += end - p + 1;
319320
}

0 commit comments

Comments
 (0)