git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 3/5] gitweb: Split validate_input into validate_pathname and validate_refname
Date: Tue, 26 Sep 2006 09:55:02 +0200	[thread overview]
Message-ID: <200609260955.02869.jnareb@gmail.com> (raw)
In-Reply-To: <7v1wpzw9l9.fsf@assigned-by-dhcp.cox.net>

Dnia wtorek 26. września 2006 06:11, Junio C Hamano napisał:
> Jakub Narebski <jnareb@gmail.com> writes:
> 
> > @@ -387,16 +400,37 @@ sub href(%) {
> >  ## 
======================================================================
> >  ## validation, quoting/unquoting and escaping
> >  
> > -sub validate_input {
> > -	my $input = shift;
> > +sub validate_pathname {
> > +	my $input = shift || return undef;
> >  
> > -	if ($input =~ m/^[0-9a-fA-F]{40}$/) {
> > -		return $input;
> > +	# no '.' or '..' as elements of path, i.e. no '.' nor '..'
> > +	# at the beginning, at the end, and between slashes.
> > +	if ($input =~ m!(^|/)(|\.|\.\.)(/|$)!) {
> > +		return undef;
> >  	}
> > -	if ($input =~ m/(^|\/)(|\.|\.\.)($|\/)/) {
> > +	# no doubled slashes
> > +	if ($input =~ m!//!) {
> >  		return undef;
> >  	}
> 
> I do not think you need the second check for double-slash.  The
> pattern you borrowed from the original:
> 
> 	/(^|\/)(|\.|\.\.)($|\/)/)
> 
> cleverly matches an empty string with $2, so you already match
> double-slash with $1 = '/' $2 = '' $3 = '/', don't you?

Do I need to resend patch, then, to remove this unnecessary check?

> > +	# it must be correct pathname
> > +	$input = validate_pathname($input)
> > +		or return undef;
> > +	# restrictions on ref name according to git-check-ref-format
> > +	if ($input =~ m!(/\.|\.\.|[\000-\040\177 ~^:?*\[]|/$)!) {
> >  		return undef;
> >  	}
> 
> Why would you need validate_pathname here?

refname _must_ be a valid pathname, no? It means for example that it
cannot have double slashes, not NUL (the only thinkg not covered by
git-check-ref-format restrictions). Well, we could add that to regexp
instead...

-- 
Jakub Narebski
Poland

  reply	other threads:[~2006-09-26  7:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-25 23:53 [PATCH 0/5] gitweb: A few code cleanup patches Jakub Narebski
2006-09-25 23:54 ` [PATCH 1/5] gitweb: Strip trailing slashes from $path in git_get_hash_by_path Jakub Narebski
2006-09-25 23:56 ` [PATCH 2/5] gitweb: Use "return" instead of "return undef" for some subs Jakub Narebski
2006-09-25 23:57 ` [PATCH 3/5] gitweb: Split validate_input into validate_pathname and validate_refname Jakub Narebski
2006-09-26  4:11   ` Junio C Hamano
2006-09-26  7:55     ` Jakub Narebski [this message]
2006-09-25 23:58 ` [PATCH 4/5] gitweb: Add git_url subroutine, and use it to quote full URLs Jakub Narebski
2006-09-25 23:59 ` [PATCH 5/5] gitweb: Quote filename in HTTP Content-Disposition: header Jakub Narebski
2006-09-26  4:11   ` Junio C Hamano
2006-09-26  7:51     ` Jakub Narebski

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=200609260955.02869.jnareb@gmail.com \
    --to=jnareb@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /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).