From 68628ccef219b50f662d598bdf627e92e393da2f Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Sun, 14 Apr 2024 18:44:50 +0100
Subject: [PATCH] Issue #3439932 by phenaproxima, narendraR, Wim Leers,
 larowlan: Add validation constraints to system.image and system.image.gd

---
 core/modules/system/config/schema/system.schema.yml | 13 +++++++++++++
 .../Core/Config/SimpleConfigValidationTest.php      |  1 +
 2 files changed, 14 insertions(+)

diff --git a/core/modules/system/config/schema/system.schema.yml b/core/modules/system/config/schema/system.schema.yml
index 72c924620c3b..03d7938e35b0 100644
--- a/core/modules/system/config/schema/system.schema.yml
+++ b/core/modules/system/config/schema/system.schema.yml
@@ -313,18 +313,31 @@ system.file:
 system.image:
   type: config_object
   label: 'Image settings'
+  constraints:
+    FullyValidatable: ~
   mapping:
     toolkit:
       type: string
       label: 'Toolkit'
+      constraints:
+        PluginExists:
+          manager: 'image.toolkit.manager'
+          interface: '\Drupal\Core\ImageToolkit\ImageToolkitInterface'
 
 system.image.gd:
   type: config_object
   label: 'Image settings'
+  constraints:
+    FullyValidatable: ~
   mapping:
     jpeg_quality:
       type: integer
       label: 'JPEG quality'
+      constraints:
+        # @see \Drupal\system\Plugin\ImageToolkit\GDToolkit::buildConfigurationForm()
+        Range:
+          min: 0
+          max: 100
 
 system.mail:
   type: config_object
diff --git a/core/tests/Drupal/KernelTests/Core/Config/SimpleConfigValidationTest.php b/core/tests/Drupal/KernelTests/Core/Config/SimpleConfigValidationTest.php
index 05e85f02f5fc..0e3ec7f1cc09 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/SimpleConfigValidationTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/SimpleConfigValidationTest.php
@@ -160,6 +160,7 @@ public function testSpecialCharacters(string $config_name, string $property, str
    *   is expected to raise a "plugin does not exist" error.
    *
    * @testWith ["system.mail", "interface.0"]
+   *   ["system.image", "toolkit"]
    */
   public function testInvalidPluginId(string $config_name, string $property): void {
     $config = $this->config($config_name);
-- 
GitLab