Skip to content

Commit c0bc226

Browse files
krnowakgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a155a5f commit c0bc226

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

gitweb/gitweb.perl

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,6 +1452,16 @@ sub validate_pathname {
14521452
return $input;
14531453
}
14541454

1455+
sub is_valid_ref_format {
1456+
my $input = shift || return undef;
1457+
1458+
# restrictions on ref name according to git-check-ref-format
1459+
if ($input =~ m!(/\.|\.\.|[\000-\040\177 ~^:?*\[]|/$)!) {
1460+
return undef;
1461+
}
1462+
return $input;
1463+
}
1464+
14551465
sub validate_refname {
14561466
my $input = shift || return undef;
14571467

@@ -1462,10 +1472,9 @@ sub validate_refname {
14621472
# it must be correct pathname
14631473
$input = validate_pathname($input)
14641474
or return undef;
1465-
# restrictions on ref name according to git-check-ref-format
1466-
if ($input =~ m!(/\.|\.\.|[\000-\040\177 ~^:?*\[]|/$)!) {
1467-
return undef;
1468-
}
1475+
# check git-check-ref-format restrictions
1476+
is_valid_ref_format($input)
1477+
or return undef;
14691478
return $input;
14701479
}
14711480

0 commit comments

Comments
 (0)