Re: [PATCH v4 10/21] hash-object: read --stdin-paths with strbuf_getline()
- From
Jeff King <peff@peff.net>
- Date
- Jan 15, 2016, 20:23 UTC
- Message-ID
- <20160115202318.GD11301@sigill.intra.peff.net>
- In-Reply-To
- <1452815916-6447-11-git-send-email-gitster@pobox.com>
On Thu, Jan 14, 2016 at 03:58:25PM -0800, Junio C Hamano wrote:
Show 20 quoted lines
> The list of paths could have been written with a DOS editor.
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
> builtin/hash-object.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/builtin/hash-object.c b/builtin/hash-object.c
> index 3bc5ec1..ff20395 100644
> --- a/builtin/hash-object.c
> +++ b/builtin/hash-object.c
> @@ -60,7 +60,7 @@ static void hash_stdin_paths(const char *type, int no_filters, unsigned flags,
> {
> struct strbuf buf = STRBUF_INIT, nbuf = STRBUF_INIT;
>
> - while (strbuf_getline_lf(&buf, stdin) != EOF) {
> + while (strbuf_getline(&buf, stdin) != EOF) {
> if (buf.buf[0] == '"') {
> strbuf_reset(&nbuf);
> if (unquote_c_style(&nbuf, buf.buf, NULL))The implication here is that the paths cannot have a trailing CR unless they are quoted. I think that is probably OK. We quote such a case ourselves, and while it's _possible_ for somebody to feed us arbitrary output that they generated themselves, I would argue that anybody not quoting CR is generating bogus output.
-Peff