From 89acf0cafc976ec2f3d15c000f4754fb0ccdbcf8 Mon Sep 17 00:00:00 2001 From: Tom van der Woerdt Date: Wed, 17 Jul 2013 18:50:04 +0200 Subject: [PATCH] Fix the Tar creator for cases where filenames aren't absolute --- src/_h5ai/server/php/inc/Archive.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/_h5ai/server/php/inc/Archive.php b/src/_h5ai/server/php/inc/Archive.php index 1a73abbc..8377b79e 100644 --- a/src/_h5ai/server/php/inc/Archive.php +++ b/src/_h5ai/server/php/inc/Archive.php @@ -86,7 +86,11 @@ class Archive { foreach (array_values($this->files) as $file) { // TAR supports filenames up to 253 chars, but the name should be split ubti a 154-byte prefix and 99-byte name - assert(substr($file, 0, strlen($root_path)) == $root_path); + if (substr($file, 0, strlen($root_path)) != $root_path) { + $file = $this->app->get_abs_path().'/'.$file; + } + if (!file_exists($file)) continue; + $local_filename = normalize_path(substr($file, strlen($root_path) + 1)); $filename_parts = array('', substr($local_filename, -99)); if (strlen($local_filename) > 99) $filename_parts[0] = substr($local_filename, 0, -99);