diff --git a/src/DependencyInjection/ExerciseHTMLPurifierExtension.php b/src/DependencyInjection/ExerciseHTMLPurifierExtension.php
index 3383d1c2..f6a5686f 100644
--- a/src/DependencyInjection/ExerciseHTMLPurifierExtension.php
+++ b/src/DependencyInjection/ExerciseHTMLPurifierExtension.php
@@ -27,7 +27,10 @@ public function load(array $configs, ContainerBuilder $container): void
// Set default serializer cache path, while ensuring a default profile is defined
$configs['html_profiles']['default']['config']['Cache.SerializerPath'] = $configs['default_cache_serializer_path'];
- $configs['html_profiles']['default']['config']['Cache.SerializerPermissions'] = $configs['default_cache_serializer_permissions'];
+
+ if (!isset($configs['html_profiles']['default']['config']['Cache.SerializerPermissions'])) {
+ $configs['html_profiles']['default']['config']['Cache.SerializerPermissions'] = $configs['default_cache_serializer_permissions'];
+ }
$serializerPaths = [];
// Drop when require Symfony > 3.4
diff --git a/tests/DependencyInjection/ExerciseHTMLPurifierExtensionTest.php b/tests/DependencyInjection/ExerciseHTMLPurifierExtensionTest.php
index 8a5937f3..fde6d8f8 100644
--- a/tests/DependencyInjection/ExerciseHTMLPurifierExtensionTest.php
+++ b/tests/DependencyInjection/ExerciseHTMLPurifierExtensionTest.php
@@ -153,6 +153,30 @@ public function testShouldAllowOverridingDefaultConfigurationCacheSerializerPerm
$this->assertRegistryHasProfiles(['default']);
}
+ public function testShouldAllowOverridingDefaultConfigurationCacheSerializerPermissionsOnDefaultProfile(): void
+ {
+ $config = [
+ 'default_cache_serializer_path' => null,
+ 'html_profiles' => [
+ 'default' => [
+ 'config' => [
+ 'AutoFormat.AutoParagraph' => true,
+ 'Cache.SerializerPermissions' => 511,
+ ],
+ ],
+ ],
+ ];
+
+ $this->extension->load([$config], $this->container);
+
+ $this->assertDefaultConfigDefinition(array_merge($config['html_profiles']['default']['config'], [
+ 'Cache.SerializerPath' => null,
+ 'Cache.SerializerPermissions' => 511,
+ ]));
+ $this->assertCacheWarmerSerializerArgs([], ['default']);
+ $this->assertRegistryHasProfiles(['default']);
+ }
+
public function testShouldNotDeepMergeOptions(): void
{
$configs = [