Fixed TarWriter adding leading slash to filenames
authorAlexander Ebert <ebert@woltlab.com>
Sun, 13 Jan 2013 21:00:12 +0000 (22:00 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 13 Jan 2013 21:00:12 +0000 (22:00 +0100)
wcfsetup/install/files/lib/system/io/TarWriter.class.php

index 2be3e9f8a0c999d975c8fc9d220ffdd644d9e3e5..9056f0b03ada9c3598b33a8160f82067f157fd42 100644 (file)
@@ -143,8 +143,9 @@ class TarWriter extends Tar {
        protected function addFile($filename, $addDir, $removeDir) {
                $filename = FileUtil::unifyDirSeperator($filename);
                $storedFilename = $filename;
-               if (!empty($removeDir)) $storedFilename = StringUtil::replaceIgnoreCase($removeDir, '', $filename);
-               if (!empty($addDir)) $storedFilename = $addDir . $storedFilename;
+               if (!empty($removeDir)) $storedFilename = StringUtil::replaceIgnoreCase(FileUtil::addTrailingSlash($removeDir), '', $filename);
+               if (!empty($addDir)) $storedFilename = FileUtil::addTrailingSlash($addDir) . FileUtil::removeLeadingSlash($storedFilename);
+               
                if (is_file($filename)) {
                        // open file
                        $file = new File($filename, 'rb');