From: Krzesimir Nowak Date: Wed, 11 Dec 2013 11:54:41 +0000 (+0100) Subject: gitweb: Move check-ref-format code into separate function X-Git-Url: https://git.ladys.computer/Gitweb/commitdiff_plain/fd0f6cb5638966a4c5b3381a9bf08cc8fe7557ba87b420284b4cfc064b7fe5c7?hp=03a52106a0b6956b2e91ce1dcfda1ecfbf49542b3d71d8ca3fa6248e47ff8520 gitweb: Move check-ref-format code into separate function This check will be used in more than one place later. Signed-off-by: Krzesimir Nowak Signed-off-by: Junio C Hamano --- diff --git a/gitweb.perl b/gitweb.perl index 7a7bf5d..a0e5de9 100755 --- a/gitweb.perl +++ b/gitweb.perl @@ -1453,6 +1453,16 @@ sub validate_pathname { return $input; } +sub is_valid_ref_format { + my $input = shift || return undef; + + # restrictions on ref name according to git-check-ref-format + if ($input =~ m!(/\.|\.\.|[\000-\040\177 ~^:?*\[]|/$)!) { + return undef; + } + return $input; +} + sub validate_refname { my $input = shift || return undef; @@ -1463,10 +1473,9 @@ sub validate_refname { # 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; - } + # check git-check-ref-format restrictions + is_valid_ref_format($input) + or return undef; return $input; }