X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FCommon.pm;h=c67c58c003f8fc9f61b623c412b6ce5e9364e022;hb=e436a6b05600897aed8c5420d44bf4e1b39cb74f;hp=fdf2b28088c6528457ab2ad2efd5974c4019c243;hpb=480c67096c7aab3ccfe6b55e8d981975c7f08578;p=kivitendo-erp.git diff --git a/SL/Common.pm b/SL/Common.pm index fdf2b2808..c67c58c00 100644 --- a/SL/Common.pm +++ b/SL/Common.pm @@ -280,6 +280,8 @@ sub webdav_folder { return $main::lxdebug->leave_sub() unless ($path && $number); + $number =~ s|[/\\]|_|g; + $path = "webdav/${path}/${number}"; if (!-d $path) { @@ -288,13 +290,24 @@ sub webdav_folder { } else { my $base_path = substr($ENV{'SCRIPT_NAME'}, 1); $base_path =~ s|[^/]+$||; + $base_path =~ s|/$||; + + if (opendir $dir, $path) { + foreach my $file (readdir $dir) { + next if (($file eq '.') || ($file eq '..')); + + my $fname = $file; + $fname =~ s|.*/||; + + my $physical_file = "$path/$file"; + + $file = join('/', map { $form->escape($_) } grep { $_ } split m|/+|, "$path/$file"); + $file .= '/' if (-d $physical_file); + + $form->{WEBDAV}->{$fname} = ($ENV{"HTTPS"} ? "https://" : "http://") . $ENV{'SERVER_NAME'} . "/$base_path/$file"; + } - foreach my $file (<$path/*>) { - my $fname = $file; - $fname =~ s|.*/||; - $form->{WEBDAV}{$fname} = - ($ENV{"HTTPS"} ? "https://" : "http://") . - $ENV{'SERVER_NAME'} . "/" . $base_path . $file; + closedir $dir; } }