Format and escaping cleanup

This commit is contained in:
Jamie Cameron 2017-12-21 23:18:32 -08:00
parent 2643b754ac
commit 20ba1a9a81

View File

@ -6,37 +6,44 @@ require './filemin-lib.pl';
get_paths(); get_paths();
if(!$in{'owner'} or !$in{'group'}) { if (!$in{'owner'} || !$in{'group'}) {
&redirect("index.cgi?path=".&urlize($path)); &redirect("index.cgi?path=".&urlize($path));
} }
(my $login, my $pass, my $uid, my $gid) = getpwnam($in{'owner'}); (my $login, my $pass, my $uid, my $gid) = getpwnam($in{'owner'});
my $grid = getgrnam($in{'group'}); my $grid = getgrnam($in{'group'});
my $recursive; my $recursive;
if($in{'recursive'} eq 'true') { $recursive = '-R'; } else { $recursive = ''; } if ($in{'recursive'} eq 'true') {
$recursive = '-R';
}
else {
$recursive = '';
}
my @errors; my @errors;
if(! defined $login) { if (!defined($login)) {
push @errors, "<b>$in{'owner'}</b> $text{'error_user_not_found'}"; push @errors, "<b>".&html_escape($in{'owner'})."</b> $text{'error_user_not_found'}";
} }
if(! defined $grid) { if (!defined($grid)) {
push @errors, "<b>$in{'group'}</b> $text{'error_group_not_found'}"; push @errors, "<b>".&html_escape($in{'group'})."</b> $text{'error_group_not_found'}";
} }
if (scalar(@errors) > 0) { if (scalar(@errors) > 0) {
print_errors(@errors); print_errors(@errors);
} else { }
foreach $name (split(/\0/, $in{'name'})) { else {
# if(!chown $uid, $grid, $cwd.'/'.$name) { foreach $name (split(/\0/, $in{'name'})) {
if(system_logged("chown $recursive $uid:$grid ".quotemeta("$cwd/$name")) != 0) { if (system_logged("chown $recursive $uid:$grid ".
push @errors, "$name - $text{'error_chown'}: $?"; quotemeta("$cwd/$name")) != 0) {
} push @errors, "$name - $text{'error_chown'}: $?";
} }
if (scalar(@errors) > 0) { }
print_errors(@errors); if (scalar(@errors) > 0) {
} else { print_errors(@errors);
&redirect("index.cgi?path=".&urlize($path)); }
} else {
} &redirect("index.cgi?path=".&urlize($path));
}
}