Re: [Bug report] git status doesn't escape paths of untracked files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



René Scharfe <l.s.r@xxxxxx> writes:

>>> +	struct strbuf sb = STRBUF_INIT;
>>> +	const char *rel = relative_path(in, prefix, &sb);
>>> +	int need_quotes = *rel != '"' && strchr(rel, ' ');
>>
>> relative_path() does not quote, so "begins with a dq" is not a good
>> test to see "if we were to pass this string to quote_c_style(), would
>> we get it back quoted already so we won't have to surround the
>> result with an extra pair of dq ourselves?".
>
> Ha!, that's true.  Makes me wonder how it was still able to pass the
> test suite, though..

The logic to refrain from ading extra dq-pair around the output from
quote-c-style is "if it is already in a dq-pair, don't bother".  The
bug will trigger only when the input string has a character that
needs to be quoted *and* SP in it.  In such a case, relative_path()
is likely to return *rel != '"' and you declare "we need to add a
dq-pair ourselves", quote-c-style would give us a result in a
dq-pair, and you add one extra layer.  

But without a test with a path with both '"' and ' ' in it, such a
bug would not trigger.  Brian's test only checks what happens to a
path with SP in it, without any other funny characters that need
quoting with quote-c-style.






[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux