diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dc363be4d..c1ed732097 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). ### Added -- Nothing +- Use tmp dir in HTMLPurifier config ### Changed diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index 9a8c0ff6df..a59ea1f931 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -1769,6 +1769,10 @@ private function writeComment(Worksheet $worksheet, $coordinate) $result = ''; if (!$this->isPdf && isset($worksheet->getComments()[$coordinate])) { $sanitizer = new HTMLPurifier(); + $cachePath = File::sysGetTempDir() . '/phpsppur'; + if (is_dir($cachePath) || mkdir($cachePath)) { + $sanitizer->config->set('Cache.SerializerPath', $cachePath); + } $sanitizedString = $sanitizer->purify($worksheet->getComment($coordinate)->getText()->getPlainText()); if ($sanitizedString !== '') { $result .= '';