git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCHv3] pathspec: allow escaped query values

From
Stefan Beller <sbeller@google.com>
Date
Jun 2, 2016, 23:41 UTC
Message-ID
<CAGZ79kas0EdQd4MJUOVFJYfm0-yaDQhJgCBpKQk5m4UrsjPBwg@mail.gmail.com>
In-Reply-To
<xmqqwpm7qio2.fsf@gitster.mtv.corp.google.com>
On Thu, Jun 2, 2016 at 4:23 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 8 quoted lines
> Stefan Beller <sbeller@google.com> writes:
>
>> However if we add a value restriction here, we need to be as strict in the
>> .gitattributes parsing as well and put a warning there (similar to
>> invalid_attr_name_message) I would think.
>
> Remember, the attribute system is used for many purposes other than
> this new "further limit pathspec".

Right, and in the past we followed a rigid pattern of non-crazy values. The crazy values will show up once users realize they can put anything they want into the .gitattributes to query for files.

Before this labeling change, there was no need to put anything other the officially documented values into the attribute files.

> So I do not think it is necessary or even beneficial to add such a
> warning.
Ok.
Show 31 quoted lines
>
>> +static char *attr_value_unescape(const char *value)
>> +{
>> +     const char *src;
>> +     char *dst, *ret;
>> +
>> +     ret = xmallocz(strlen(value));
>> +     for (src = value, dst = ret; *src; src++, dst++) {
>> +             if (*src == '\\') {
>> +                     if (!src[1])
>> +                             die(_("Escape character '\\' not allowed as "
>> +                                   "last character in attr value"));
>> +                     src++;
>> +             }
>> +             if (*src && invalid_value_char(*src))
>> +                     die("cannot use '%c' for value matching", *src);
>> +             *dst = *src;
>> +     }
>> +     *dst = '\0';
>> +     return ret;
>> +}
>
> Please sanity-check me.  Just like I said to your original "I doubt
> *i could be NUL here", I now doubt *src could be NUL there where
> invalid_value_char() gets called.
>
> If *src could be NUL there, then *dst gets NUL once, and then after
> loop exits (presumably after incrementing dst), *dst gets another
> NUL, which was the terminating NUL condition being iffy I mentioned,
> but as you said, I do not think it would happen, so we can lose the
> "*src && " before invalid_value_char() is called.

Right, we can lose the *src check before invalid_value_char as that ought to be caught in if (!src[1]) die(...) before.

Thanks, Stefan

>
> Thanks.
Previous: Junio C Hamano
Message 3 of 3 in “[PATCHv3] pathspec: allow escaped query values”
  1. Stefan BellerJun 2, 2016
  2. Junio C HamanoJun 2, 2016
  3. Stefan BellerJun 2, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.