@@ -994,59 +994,59 @@ sub evaluate_path_info {
994
994
sub evaluate_and_validate_params {
995
995
our $action = $input_params {' action' };
996
996
if (defined $action ) {
997
- if (!validate_action ($action )) {
997
+ if (!is_valid_action ($action )) {
998
998
die_error(400, " Invalid action parameter" );
999
999
}
1000
1000
}
1001
1001
1002
1002
# parameters which are pathnames
1003
1003
our $project = $input_params {' project' };
1004
1004
if (defined $project ) {
1005
- if (!validate_project ($project )) {
1005
+ if (!is_valid_project ($project )) {
1006
1006
undef $project ;
1007
1007
die_error(404, " No such project" );
1008
1008
}
1009
1009
}
1010
1010
1011
1011
our $project_filter = $input_params {' project_filter' };
1012
1012
if (defined $project_filter ) {
1013
- if (!validate_pathname ($project_filter )) {
1013
+ if (!is_valid_pathname ($project_filter )) {
1014
1014
die_error(404, " Invalid project_filter parameter" );
1015
1015
}
1016
1016
}
1017
1017
1018
1018
our $file_name = $input_params {' file_name' };
1019
1019
if (defined $file_name ) {
1020
- if (!validate_pathname ($file_name )) {
1020
+ if (!is_valid_pathname ($file_name )) {
1021
1021
die_error(400, " Invalid file parameter" );
1022
1022
}
1023
1023
}
1024
1024
1025
1025
our $file_parent = $input_params {' file_parent' };
1026
1026
if (defined $file_parent ) {
1027
- if (!validate_pathname ($file_parent )) {
1027
+ if (!is_valid_pathname ($file_parent )) {
1028
1028
die_error(400, " Invalid file parent parameter" );
1029
1029
}
1030
1030
}
1031
1031
1032
1032
# parameters which are refnames
1033
1033
our $hash = $input_params {' hash' };
1034
1034
if (defined $hash ) {
1035
- if (!validate_refname ($hash )) {
1035
+ if (!is_valid_refname ($hash )) {
1036
1036
die_error(400, " Invalid hash parameter" );
1037
1037
}
1038
1038
}
1039
1039
1040
1040
our $hash_parent = $input_params {' hash_parent' };
1041
1041
if (defined $hash_parent ) {
1042
- if (!validate_refname ($hash_parent )) {
1042
+ if (!is_valid_refname ($hash_parent )) {
1043
1043
die_error(400, " Invalid hash parent parameter" );
1044
1044
}
1045
1045
}
1046
1046
1047
1047
our $hash_base = $input_params {' hash_base' };
1048
1048
if (defined $hash_base ) {
1049
- if (!validate_refname ($hash_base )) {
1049
+ if (!is_valid_refname ($hash_base )) {
1050
1050
die_error(400, " Invalid hash base parameter" );
1051
1051
}
1052
1052
}
@@ -1066,7 +1066,7 @@ sub evaluate_and_validate_params {
1066
1066
1067
1067
our $hash_parent_base = $input_params {' hash_parent_base' };
1068
1068
if (defined $hash_parent_base ) {
1069
- if (!validate_refname ($hash_parent_base )) {
1069
+ if (!is_valid_refname ($hash_parent_base )) {
1070
1070
die_error(400, " Invalid hash parent base parameter" );
1071
1071
}
1072
1072
}
@@ -1418,27 +1418,30 @@ sub href {
1418
1418
# # ======================================================================
1419
1419
# # validation, quoting/unquoting and escaping
1420
1420
1421
- sub validate_action {
1422
- my $input = shift || return undef ;
1421
+ sub is_valid_action {
1422
+ my $input = shift ;
1423
1423
return undef unless exists $actions {$input };
1424
- return $input ;
1424
+ return 1 ;
1425
1425
}
1426
1426
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 ) ||
1430
1432
!(-d " $projectroot /$input " ) ||
1431
1433
!check_export_ok(" $projectroot /$input " ) ||
1432
1434
($strict_export && !project_in_list($input ))) {
1433
1435
return undef ;
1434
1436
} else {
1435
- return $input ;
1437
+ return 1 ;
1436
1438
}
1437
1439
}
1438
1440
1439
- sub validate_pathname {
1440
- my $input = shift || return undef ;
1441
+ sub is_valid_pathname {
1442
+ my $input = shift ;
1441
1443
1444
+ return undef unless defined $input ;
1442
1445
# no '.' or '..' as elements of path, i.e. no '.' nor '..'
1443
1446
# at the beginning, at the end, and between slashes.
1444
1447
# also this catches doubled slashes
@@ -1449,33 +1452,33 @@ sub validate_pathname {
1449
1452
if ($input =~ m !\0 ! ) {
1450
1453
return undef ;
1451
1454
}
1452
- return $input ;
1455
+ return 1 ;
1453
1456
}
1454
1457
1455
1458
sub is_valid_ref_format {
1456
- my $input = shift || return undef ;
1459
+ my $input = shift ;
1457
1460
1461
+ return undef unless defined $input ;
1458
1462
# restrictions on ref name according to git-check-ref-format
1459
1463
if ($input =~ m ! (/\. |\.\. |[\000 -\040\177 ~^:?*\[ ]|/$ )! ) {
1460
1464
return undef ;
1461
1465
}
1462
- return $input ;
1466
+ return 1 ;
1463
1467
}
1464
1468
1465
- sub validate_refname {
1466
- my $input = shift || return undef ;
1469
+ sub is_valid_refname {
1470
+ my $input = shift ;
1467
1471
1472
+ return undef unless defined $input ;
1468
1473
# textual hashes are O.K.
1469
1474
if ($input =~ m / ^[0-9a-fA-F] {40}$ / ) {
1470
- return $input ;
1475
+ return 1 ;
1471
1476
}
1472
1477
# it must be correct pathname
1473
- $input = validate_pathname($input )
1474
- or return undef ;
1478
+ is_valid_pathname($input ) or return undef ;
1475
1479
# 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;
1479
1482
}
1480
1483
1481
1484
# decode sequences of octets in utf8 into Perl's internal form,
0 commit comments