Fix an infinite loop in sq_quote_buf().
sq_quote_buf() treats single-quotes and exclamation marks specially, but it incorrectly parsed the input for single-quotes and backslashes. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Sixt committed
Nov 4, 2007 at 21:26 UTC
c2015b3ae0d52ccae33ee00c2b25b8402c66bdf0
2 files changed
+8
-1
quote.c
+1
-1
@@ -26,7 +26,7 @@ void sq_quote_buf(struct strbuf *dst, const char *src)
26
27
strbuf_addch(dst, '\'');
28
while (*src) {
29
- size_t len = strcspn(src, "'\\");
29
+ size_t len = strcspn(src, "'!");
30
strbuf_add(dst, src, len);
31
src += len;
32
while (need_bs_quote(*src)) {
t/t5510-fetch.sh
+7
@@ -208,4 +208,11 @@ test_expect_success 'fetch with a non-applying branch.<name>.merge' '
208
git fetch blub
209
'
210
211
+# the strange name is: a\!'b
212
+test_expect_success 'quoting of a strangely named repo' '
213
+ ! git fetch "a\\!'\''b" > result 2>&1 &&
214
+ cat result &&
215
+ grep "fatal: '\''a\\\\!'\''b'\''" result
216
+'
217
+
218
test_done