git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Shinya Kuribayashi <skuribay@pobox.com>
To: Max Kellermann <max@duempel.org>
Cc: git@vger.kernel.org
Subject: Re: [stgit PATCH] commands.{new,rename}: verify patch names
Date: Wed, 03 Nov 2010 11:43:29 +0900	[thread overview]
Message-ID: <4CD0CC51.5030402@pobox.com> (raw)
In-Reply-To: <20101005125631.17466.95192.stgit@woodpecker.blarg.de>

Hi,

On 10/5/10 9:56 PM, Max Kellermann wrote:
> Don't allow patches with invalid names.  For example, a patch with a
> slash in the name will cause the underlying git command to fail, and
> stgit doesn't handle this error condition properly.
> ---
>   stgit/commands/new.py    |    3 +++
>   stgit/commands/rename.py |    3 +++
>   stgit/utils.py           |    6 ++++++
>   3 files changed, 12 insertions(+), 0 deletions(-)

It would be nice to mention about what's updated when revising
patches, even though it's even +1 line.  And we'd also like to
have a sign within Subject:, e.g., [stgit PATCH v2] will suffice.

> diff --git a/stgit/utils.py b/stgit/utils.py
> index 2955adf..a41457b 100644
> --- a/stgit/utils.py
> +++ b/stgit/utils.py
> @@ -241,6 +241,12 @@ def make_patch_name(msg, unacceptable, default_name = 'patch'):
>           patchname = default_name
>       return find_patch_name(patchname, unacceptable)
>
> +def check_patch_name(name):
> +    """Checks if the specified name is a valid patch name. For
> +    technical reasons, we cannot allow a slash and other characters."""
> +    return len(name)>  0 and name[0] not in '.-' and '/' not in name and \
> +           '..' not in name and re.search(r'[\x00-\x20]', name) is None
> +
>   # any and all functions are builtin in Python 2.5 and higher, but not
>   # in 2.4.
>   if not 'any' in dir(__builtins__):

".." is now taken care, too.  That's nice.

By the way, you're not the first person encountered this issue,
and we already have corresponding bug# at gna.org, you might be
interested in:

* https://gna.org/bugs/?10919
   sanity check patch names

* https://gna.org/bugs/?15654
   stg new when path contains slash stops stg from doing everything

I don't speak Python, so couldn't help the patch itself.
Catalin and Karl hopefully will guide you (they seem to busy
these days, or just failed to find this thread).

  reply	other threads:[~2010-11-03  2:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-05 12:56 [stgit PATCH] commands.{new,rename}: verify patch names Max Kellermann
2010-11-03  2:43 ` Shinya Kuribayashi [this message]
  -- strict thread matches above, loose matches on Subject: below --
2010-10-05 11:45 Max Kellermann
2010-10-05 12:44 ` Gustav Hållberg
2010-10-05 12:52   ` Max Kellermann

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=4CD0CC51.5030402@pobox.com \
    --to=skuribay@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=max@duempel.org \
    /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).