From 52723ad93381d2934132eacb7e3f56dc7c76dc78 Mon Sep 17 00:00:00 2001 From: Mannes Date: Wed, 5 Oct 2016 17:14:48 +0200 Subject: [PATCH] Check for file exists before adding to zip. Adding a non existent file to ZipArchive can lead to archive not being created --- h5p.classes.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index 4a3203a..d9f1af2 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1586,8 +1586,8 @@ Class H5PExport { foreach ($files as $file) { // Please note that the zip format has no concept of folders, we must // use forward slashes to separate our directories. - $zip->addFile($file->absolutePath, $file->relativePath); - $zip->addFile($rootPrefix . $file->absolutePath, $file->relativePath); + if (file_exists($file->absolutePath)) $zip->addFile($file->absolutePath, $file->relativePath); + if (file_exists($rootPrefix . $file->absolutePath)) $zip->addFile($rootPrefix . $file->absolutePath, $file->relativePath); } // Close zip and remove tmp dir