Use realpath() instead of document root = safer

Document root might be rewritten or incorrect for some sites(observed on multiple WP)
HFP-784
pull/38/head
Frode Petterson 2017-02-22 11:25:05 +01:00
parent c4b88c3992
commit 79fa5076f2
1 changed files with 1 additions and 5 deletions

View File

@ -1589,15 +1589,11 @@ Class H5PExport {
$zip = new ZipArchive();
$zip->open($tmpFile, ZipArchive::CREATE | ZipArchive::OVERWRITE);
// Some system needs the root prefix for ZipArchive's addFile()
$rootPrefix = (empty($_SERVER['DOCUMENT_ROOT']) ? '' : $_SERVER['DOCUMENT_ROOT'] . '/');
// Add all the files from the tmp dir.
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);
$zip->addFile(realpath($file->absolutePath), $file->relativePath);
}
// Close zip and remove tmp dir