Create new files with same ownership as parent (and add some missing escaping)

This commit is contained in:
Jamie Cameron
2017-05-29 16:16:14 -07:00
parent 74d463be57
commit 40db0575f6
2 changed files with 24 additions and 16 deletions

View File

@@ -5,17 +5,25 @@ require './filemin-lib.pl';
get_paths();
if(!$in{'name'}) {
&redirect("index.cgi?path=$path");
}
if (!$in{'name'}) {
&redirect("index.cgi?path=".&urlize($path));
return;
}
my $full = "$cwd/$in{'name'}";
if (-e $full) {
print_errors(&html_escape($in{'name'})." ".$text{'error_exists'});
}
else {
my @st = stat($cwd);
if (open(my $fh, ">$full")) {
close($fh);
&set_ownership_permissions($st[4], $st[5], undef, $full);
&redirect("index.cgi?path=".&urlize($path));
}
else {
print_errors($text{'error_create'}." ".
&html_escape($in{'name'})." : ".$!);
}
}
if (-f "$cwd/$in{'name'}") {
print_errors("$in{'name'} $text{'error_exists'}");
} else {
if (open my $fh, "> $cwd/$in{'name'}") {
close($fh);
&redirect("index.cgi?path=$path");
} else {
print_errors("$in{'name'} - $text{'error_create'} $!");
}
}

View File

@@ -6,19 +6,19 @@ require './filemin-lib.pl';
get_paths();
if (!$in{'name'}) {
&redirect("index.cgi?path=$path");
&redirect("index.cgi?path=".&urlize($path));
return;
}
my $full = "$cwd/$in{'name'}";
if (-d $full) {
if (-e $full) {
print_errors(&html_escape($in{'name'})." ".$text{'error_exists'});
}
else {
my @st = stat($cwd);
if (&make_dir($full, oct(755)) ) {
&set_ownership_permissions($st[4], $st[5], undef, $full);
&redirect("index.cgi?path=$path");
&redirect("index.cgi?path=".&urlize($path));
}
else {
print_errors($text{'error_create'}." ".