Skip to content

Commit f54f507

Browse files
committed
Merge branch 'v25-12' into release
2 parents f484fbc + e1de1f0 commit f54f507

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

app/Util/ConfiguredHtmlPurifier.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@ class ConfiguredHtmlPurifier
2222

2323
public function __construct()
2424
{
25+
// This is done by the web-server at run-time, with the existing
26+
// storage/framework/cache folder to ensure we're using a server-writable folder.
27+
$cachePath = storage_path('framework/cache/purifier');
28+
$this->createCacheFolderIfNeeded($cachePath);
29+
2530
$config = HTMLPurifier_HTML5Config::createDefault();
26-
$this->setConfig($config);
31+
$this->setConfig($config, $cachePath);
2732
$this->resetCacheIfNeeded($config);
2833

2934
$htmlDef = $config->getDefinition('HTML', true, true);
@@ -34,6 +39,13 @@ public function __construct()
3439
$this->purifier = new HTMLPurifier($config);
3540
}
3641

42+
protected function createCacheFolderIfNeeded(string $cachePath): void
43+
{
44+
if (!file_exists($cachePath)) {
45+
mkdir($cachePath, 0777, true);
46+
}
47+
}
48+
3749
protected function resetCacheIfNeeded(HTMLPurifier_Config $config): void
3850
{
3951
if (self::$cachedChecked) {
@@ -53,9 +65,9 @@ protected function resetCacheIfNeeded(HTMLPurifier_Config $config): void
5365
self::$cachedChecked = true;
5466
}
5567

56-
protected function setConfig(HTMLPurifier_Config $config): void
68+
protected function setConfig(HTMLPurifier_Config $config, string $cachePath): void
5769
{
58-
$config->set('Cache.SerializerPath', storage_path('framework/purifier'));
70+
$config->set('Cache.SerializerPath', $cachePath);
5971
$config->set('Core.AllowHostnameUnderscore', true);
6072
$config->set('CSS.AllowTricky', true);
6173
$config->set('HTML.SafeIframe', true);

storage/framework/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ routes.php
77
routes.scanned.php
88
schedule-*
99
services.json
10+
purifier/

storage/framework/purifier/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)