diff --git a/Services/HtmlSanitiser.php b/Services/HtmlSanitiser.php
index c26f93b..bfad7de 100644
--- a/Services/HtmlSanitiser.php
+++ b/Services/HtmlSanitiser.php
@@ -97,20 +97,6 @@ class HtmlSanitiser
$config->set('HTML.Nofollow', true);
$config->set('HTML.TargetNoopener', true);
- // Disable cache and set definition ID for custom HTML definitions
- $config->set('Cache.DefinitionImpl', null);
- $config->set('HTML.DefinitionID', 'core-content-html5');
- $config->set('HTML.DefinitionRev', 1);
-
- // Register HTML5 elements that HTMLPurifier doesn't know about
- if ($def = $config->maybeGetRawHTMLDefinition()) {
- $def->addElement('section', 'Block', 'Flow', 'Common');
- $def->addElement('article', 'Block', 'Flow', 'Common');
- $def->addElement('figure', 'Block', 'Flow', 'Common');
- $def->addElement('figcaption', 'Inline', 'Flow', 'Common');
- $def->addElement('mark', 'Inline', 'Inline', 'Common');
- }
-
// Safe URI schemes only
$config->set('URI.AllowedSchemes', [
'http' => true,
@@ -123,6 +109,22 @@ class HtmlSanitiser
$config->set('URI.DisableExternalResources', false);
$config->set('URI.DisableResources', false);
+ // Disable cache and set definition ID for custom HTML definitions
+ $config->set('Cache.DefinitionImpl', null);
+ $config->set('HTML.DefinitionID', 'core-content-html5');
+ $config->set('HTML.DefinitionRev', 1);
+
+ // Register HTML5 elements that HTMLPurifier doesn't know about
+ // NOTE: maybeGetRawHTMLDefinition() finalizes the config — all
+ // $config->set() calls must come before this point.
+ if ($def = $config->maybeGetRawHTMLDefinition()) {
+ $def->addElement('section', 'Block', 'Flow', 'Common');
+ $def->addElement('article', 'Block', 'Flow', 'Common');
+ $def->addElement('figure', 'Block', 'Flow', 'Common');
+ $def->addElement('figcaption', 'Inline', 'Flow', 'Common');
+ $def->addElement('mark', 'Inline', 'Inline', 'Common');
+ }
+
$this->purifier = new HTMLPurifier($config);
}
diff --git a/tests/TestCase.php b/tests/TestCase.php
index 1434eee..48fcd42 100644
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -30,28 +30,7 @@ abstract class TestCase extends BaseTestCase
// Stub external dependencies not available in test environment
if (! class_exists(\Plug\Cdn\CdnManager::class)) {
- $app->bind(\Core\Mod\Content\Services\CdnPurgeService::class, fn () => new class
- {
- public function isEnabled(): bool
- {
- return false;
- }
-
- public function purgeContent($content)
- {
- return null;
- }
-
- public function purgeUrls(array $urls)
- {
- return null;
- }
-
- public function purgeWorkspace(string $uuid)
- {
- return null;
- }
- });
+ $app->bind(\Core\Mod\Content\Services\CdnPurgeService::class, fn () => \Mockery::mock(\Core\Mod\Content\Services\CdnPurgeService::class)->shouldIgnoreMissing());
}
}
}