@@ -994,59 +994,59 @@ sub evaluate_path_info {
994994sub evaluate_and_validate_params {
995995 our $action = $input_params {' action' };
996996 if (defined $action ) {
997- if (!validate_action ($action )) {
997+ if (!is_valid_action ($action )) {
998998 die_error(400, " Invalid action parameter" );
999999 }
10001000 }
10011001
10021002 # parameters which are pathnames
10031003 our $project = $input_params {' project' };
10041004 if (defined $project ) {
1005- if (!validate_project ($project )) {
1005+ if (!is_valid_project ($project )) {
10061006 undef $project ;
10071007 die_error(404, " No such project" );
10081008 }
10091009 }
10101010
10111011 our $project_filter = $input_params {' project_filter' };
10121012 if (defined $project_filter ) {
1013- if (!validate_pathname ($project_filter )) {
1013+ if (!is_valid_pathname ($project_filter )) {
10141014 die_error(404, " Invalid project_filter parameter" );
10151015 }
10161016 }
10171017
10181018 our $file_name = $input_params {' file_name' };
10191019 if (defined $file_name ) {
1020- if (!validate_pathname ($file_name )) {
1020+ if (!is_valid_pathname ($file_name )) {
10211021 die_error(400, " Invalid file parameter" );
10221022 }
10231023 }
10241024
10251025 our $file_parent = $input_params {' file_parent' };
10261026 if (defined $file_parent ) {
1027- if (!validate_pathname ($file_parent )) {
1027+ if (!is_valid_pathname ($file_parent )) {
10281028 die_error(400, " Invalid file parent parameter" );
10291029 }
10301030 }
10311031
10321032 # parameters which are refnames
10331033 our $hash = $input_params {' hash' };
10341034 if (defined $hash ) {
1035- if (!validate_refname ($hash )) {
1035+ if (!is_valid_refname ($hash )) {
10361036 die_error(400, " Invalid hash parameter" );
10371037 }
10381038 }
10391039
10401040 our $hash_parent = $input_params {' hash_parent' };
10411041 if (defined $hash_parent ) {
1042- if (!validate_refname ($hash_parent )) {
1042+ if (!is_valid_refname ($hash_parent )) {
10431043 die_error(400, " Invalid hash parent parameter" );
10441044 }
10451045 }
10461046
10471047 our $hash_base = $input_params {' hash_base' };
10481048 if (defined $hash_base ) {
1049- if (!validate_refname ($hash_base )) {
1049+ if (!is_valid_refname ($hash_base )) {
10501050 die_error(400, " Invalid hash base parameter" );
10511051 }
10521052 }
@@ -1066,7 +1066,7 @@ sub evaluate_and_validate_params {
10661066
10671067 our $hash_parent_base = $input_params {' hash_parent_base' };
10681068 if (defined $hash_parent_base ) {
1069- if (!validate_refname ($hash_parent_base )) {
1069+ if (!is_valid_refname ($hash_parent_base )) {
10701070 die_error(400, " Invalid hash parent base parameter" );
10711071 }
10721072 }
@@ -1418,27 +1418,30 @@ sub href {
14181418# # ======================================================================
14191419# # validation, quoting/unquoting and escaping
14201420
1421- sub validate_action {
1422- my $input = shift || return undef ;
1421+ sub is_valid_action {
1422+ my $input = shift ;
14231423 return undef unless exists $actions {$input };
1424- return $input ;
1424+ return 1 ;
14251425}
14261426
1427- sub validate_project {
1428- my $input = shift || return undef ;
1429- if (!validate_pathname($input ) ||
1427+ sub is_valid_project {
1428+ my $input = shift ;
1429+
1430+ return unless defined $input ;
1431+ if (!is_valid_pathname($input ) ||
14301432 !(-d " $projectroot /$input " ) ||
14311433 !check_export_ok(" $projectroot /$input " ) ||
14321434 ($strict_export && !project_in_list($input ))) {
14331435 return undef ;
14341436 } else {
1435- return $input ;
1437+ return 1 ;
14361438 }
14371439}
14381440
1439- sub validate_pathname {
1440- my $input = shift || return undef ;
1441+ sub is_valid_pathname {
1442+ my $input = shift ;
14411443
1444+ return undef unless defined $input ;
14421445 # no '.' or '..' as elements of path, i.e. no '.' nor '..'
14431446 # at the beginning, at the end, and between slashes.
14441447 # also this catches doubled slashes
@@ -1449,33 +1452,33 @@ sub validate_pathname {
14491452 if ($input =~ m !\0 ! ) {
14501453 return undef ;
14511454 }
1452- return $input ;
1455+ return 1 ;
14531456}
14541457
14551458sub is_valid_ref_format {
1456- my $input = shift || return undef ;
1459+ my $input = shift ;
14571460
1461+ return undef unless defined $input ;
14581462 # restrictions on ref name according to git-check-ref-format
14591463 if ($input =~ m ! (/\. |\.\. |[\000 -\040\177 ~^:?*\[ ]|/$ )! ) {
14601464 return undef ;
14611465 }
1462- return $input ;
1466+ return 1 ;
14631467}
14641468
1465- sub validate_refname {
1466- my $input = shift || return undef ;
1469+ sub is_valid_refname {
1470+ my $input = shift ;
14671471
1472+ return undef unless defined $input ;
14681473 # textual hashes are O.K.
14691474 if ($input =~ m / ^[0-9a-fA-F] {40}$ / ) {
1470- return $input ;
1475+ return 1 ;
14711476 }
14721477 # it must be correct pathname
1473- $input = validate_pathname($input )
1474- or return undef ;
1478+ is_valid_pathname($input ) or return undef ;
14751479 # check git-check-ref-format restrictions
1476- is_valid_ref_format($input )
1477- or return undef ;
1478- return $input ;
1480+ is_valid_ref_format($input ) or return undef ;
1481+ return 1;
14791482}
14801483
14811484# decode sequences of octets in utf8 into Perl's internal form,
0 commit comments