From: Junio C Hamano <gitster@pobox.com>
To: Stefan Beller <sbeller@google.com>
Cc: git@vger.kernel.org, pclouds@gmail.com, ramsay@ramsayjones.plus.com
Subject: Re: [PATCHv3] pathspec: allow escaped query values
Date: Thu, 02 Jun 2016 16:23:41 -0700 [thread overview]
Message-ID: <xmqqwpm7qio2.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20160602231413.9028-1-sbeller@google.com> (Stefan Beller's message of "Thu, 2 Jun 2016 16:14:13 -0700")
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". While the (hopefully temporary)
limitation hurts here, users will limit the attributes they use for
":(attr:VAR=VAL)" pathspec magic, and it is unlikely that either the
VAR part or its VALue are something the core Git currently uses
anyway.
So I do not think it is necessary or even beneficial to add such a
warning.
> +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.
Thanks.
next prev parent reply other threads:[~2016-06-02 23:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-02 23:14 [PATCHv3] pathspec: allow escaped query values Stefan Beller
2016-06-02 23:23 ` Junio C Hamano [this message]
2016-06-02 23:41 ` Stefan Beller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqwpm7qio2.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
--cc=ramsay@ramsayjones.plus.com \
--cc=sbeller@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).