From df6d932f355528b00d6797564f67f7e7ecd32944 Mon Sep 17 00:00:00 2001 From: Marc MAURICE Date: Tue, 14 Jun 2011 23:36:04 +0200 Subject: [PATCH] tar plugin now supports utf8 (got rid of escapeshellarg function) extra check to see if tar will work --- plugins/tar/tar.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/tar/tar.php b/plugins/tar/tar.php index 3864e1a..9d3a46f 100644 --- a/plugins/tar/tar.php +++ b/plugins/tar/tar.php @@ -48,14 +48,19 @@ if ( ! is_dir($realDir) ) { # change to the parent directory chdir(dirname($realDir)); -$filesarg = escapeshellarg(basename($realDir))."/*"; +$filesarg = basename($realDir); +# same as escapeshellarg function but this supports utf8 regardless of locale +$filesarg = "'".str_replace("'", "'\\''", $filesarg)."'"; +$filesarg = "$filesarg/*"; # compute and send content-length header if ($SEND_CONTENT_LENGTH) { - $out = exec("tar $TAR_FLAGS --totals -cf /dev/null $filesarg 2>&1"); + $out = exec("tar $TAR_FLAGS --totals -cf /dev/null $filesarg 2>&1", $output, $ret); preg_match('/^Total bytes written: ([0-9]+) /', $out, $matches); $totalsize = $matches[1]; + ($totalsize > 1000 and $ret === 0) or die("Could not tar: $filesarg. Try checking permissions."); + header("Content-Length: $totalsize"); } -- 1.7.10.4