git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: Phillip Wood <phillip.wood@dunelm.org.uk>
Cc: Git List <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: [PATCH v4 2/2] sequencer: fix quoting in write_author_script
Date: Wed, 8 Aug 2018 04:43:43 -0400	[thread overview]
Message-ID: <CAPig+cQdH+Xiunej1E6EnA6btFzZJTPo27cFY_UdaFZF7J7t-w@mail.gmail.com> (raw)
In-Reply-To: <753b860e-c922-fd70-9d2d-0581976a6f37@talktalk.net>

On Tue, Aug 7, 2018 at 9:54 AM Phillip Wood <phillip.wood@talktalk.net> wrote:
> On 07/08/18 11:23, Eric Sunshine wrote:
> > On Tue, Aug 7, 2018 at 5:35 AM Phillip Wood <phillip.wood@talktalk.net> wrote:
> >> +       if (n > 0 && s[n] != '\'')
> >> +               return 1;
> >
> > To be "technically correct", I think the condition in the 'if'
> > statement should be ">=". It should never happen in practice that the
> > entire content of the file is a single character followed by zero or
> > more newlines, but using the proper condition ">=" would save future
> > readers of this code a "huh?" moment.
>
> I'm not sure it is that simple. If the script consists solely of a
> single quote then we should return 1, if it is a single character that
> is not "'" then it should return 0. Currently it returns 0 in both those
> cases so is technically broken when the script is "'". If it used ">="
> instead then I think it would return 0 when it should return 1 and vice
> versa. As you say this shouldn't happen in practice.

It shouldn't happen in practice, but if a human (power user) edits
this file, we shouldn't discount the possibility. However, I'm not so
concerned about quoting_is_broken() returning a meaningful answer in
this case since we have much bigger problems if we get such a file.
(Indeed, what answer could quoting_is_broken() return which would be
useful or meaningful for such a malformed file?)

What does concern me is that read_env_script() doesn't seem to care
about such a malformed file; it doesn't do any validation at all.
Contrast that with read_author_ident() which is pretty strict about
the content it expects to find in the file. So, it might make sense to
upgrade read_env_script() to do some sort of validation on each line
(though that shouldn't be in this patch, and doesn't even need to be
in this series). For instance, it could check that each line looks
something like what would be matched by this regex: /[A-Z0-9_]+='.+'/

(And, no, I'm not saying that regex should be used for validation; I'm
just using it as an example.)

As for '>' vs. '>=', it caused more than a slight hiccup when I was
scanning the code, and I worry that future readers could be similarly
impacted.

  reply	other threads:[~2018-08-08  8:43 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-31  7:33 [PATCH v2 0/4] fix "rebase -i --root" corrupting root commit Eric Sunshine
2018-07-31  7:33 ` [PATCH v2 1/4] sequencer: fix "rebase -i --root" corrupting author header Eric Sunshine
2018-07-31  7:33 ` [PATCH v2 2/4] sequencer: fix "rebase -i --root" corrupting author header timezone Eric Sunshine
2018-07-31  9:50   ` Phillip Wood
2018-07-31 10:15     ` Eric Sunshine
2018-07-31  7:33 ` [PATCH v2 3/4] sequencer: fix "rebase -i --root" corrupting author header timestamp Eric Sunshine
2018-07-31 10:00   ` Phillip Wood
2018-07-31 10:30     ` Eric Sunshine
2018-07-31  7:33 ` [PATCH v2 4/4] sequencer: don't die() on bogus user-edited timestamp Eric Sunshine
2018-07-31 10:02   ` Phillip Wood
2018-07-31 10:38     ` Eric Sunshine
2018-07-31 10:05 ` [PATCH v2 0/4] fix "rebase -i --root" corrupting root commit Phillip Wood
2018-07-31 10:46   ` Eric Sunshine
2018-07-31 11:19     ` Phillip Wood
2018-07-31 11:27     ` Eric Sunshine
2018-07-31 11:15 ` [PATCH v2 0/2] Fix author script quoting Phillip Wood
2018-07-31 11:15   ` [PATCH v2 1/2] sequencer: handle errors in read_author_ident() Phillip Wood
2018-07-31 20:47     ` Eric Sunshine
2018-08-01  9:28       ` Phillip Wood
2018-07-31 11:15   ` [PATCH v2 2/2] sequencer: fix quoting in write_author_script Phillip Wood
2018-07-31 21:39     ` Eric Sunshine
2018-08-01 10:24       ` Phillip Wood
2018-08-01 15:22         ` Junio C Hamano
2018-08-01 15:50       ` Phillip Wood
2018-08-01 19:19         ` Eric Sunshine
2018-08-01  1:30 ` [PATCH v2 0/4] fix "rebase -i --root" corrupting root commit Hilco Wijbenga
2018-08-01  6:22   ` Eric Sunshine
2018-08-07  1:19     ` Hilco Wijbenga
2018-08-07  3:31       ` Eric Sunshine
2018-08-07 21:09         ` Junio C Hamano
2018-08-27 22:34         ` Johannes Schindelin
2018-08-01 23:25 ` brian m. carlson
2018-08-02  8:09   ` Eric Sunshine
2018-08-02 11:20 ` [PATCH v3 0/2] Fix author script quoting Phillip Wood
2018-08-02 11:20   ` [PATCH v3 1/2] sequencer: handle errors in read_author_ident() Phillip Wood
2018-08-03  7:09     ` Eric Sunshine
2018-08-03 15:53       ` Junio C Hamano
2018-08-02 11:20   ` [PATCH v3 2/2] sequencer: fix quoting in write_author_script Phillip Wood
2018-08-02 17:27     ` Junio C Hamano
2018-08-03  7:59       ` Eric Sunshine
2018-08-03  9:33         ` Phillip Wood
2018-08-03 10:02           ` Eric Sunshine
2018-08-03 14:12             ` Phillip Wood
2018-08-07 17:20               ` Junio C Hamano
2018-08-07  9:34 ` [PATCH v4 0/2] fix author-script quoting Phillip Wood
2018-08-07  9:34   ` [PATCH v4 1/2] sequencer: handle errors from read_author_ident() Phillip Wood
2018-08-08  9:43     ` Eric Sunshine
2018-08-07  9:34   ` [PATCH v4 2/2] sequencer: fix quoting in write_author_script Phillip Wood
2018-08-07 10:23     ` Eric Sunshine
2018-08-07 13:54       ` Phillip Wood
2018-08-08  8:43         ` Eric Sunshine [this message]
2018-08-08 16:01           ` Junio C Hamano
2018-08-09 10:06             ` Phillip Wood
2018-08-09 10:08           ` Phillip Wood
2018-08-08  9:39     ` Eric Sunshine
2018-08-09 10:11       ` Phillip Wood
2018-08-08  9:51   ` [PATCH v4 0/2] fix author-script quoting Eric Sunshine

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPig+cQdH+Xiunej1E6EnA6btFzZJTPo27cFY_UdaFZF7J7t-w@mail.gmail.com \
    --to=sunshine@sunshineco.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=phillip.wood@dunelm.org.uk \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).