From d3fa5fa93b36ce94aceea3211fae0413c6483318 Mon Sep 17 00:00:00 2001
From: Pierre Dureau <31905-pdureau@users.noreply.drupalcode.org>
Date: Fri, 9 May 2025 19:13:59 +0200
Subject: [PATCH] Issue #3519917 by penyaskito, pdureau, larowlan: Disable
 additionalProperties in slots in SDC json schema

---
 core/assets/schemas/v1/metadata-full.schema.json    |  1 +
 core/assets/schemas/v1/metadata.schema.json         |  1 +
 .../Core/Theme/Component/ComponentValidatorTest.php | 13 +++++++++++++
 3 files changed, 15 insertions(+)

diff --git a/core/assets/schemas/v1/metadata-full.schema.json b/core/assets/schemas/v1/metadata-full.schema.json
index 8cda1cb413b2..ac275eb1bdfb 100644
--- a/core/assets/schemas/v1/metadata-full.schema.json
+++ b/core/assets/schemas/v1/metadata-full.schema.json
@@ -4,6 +4,7 @@
   "$defs": {
     "slotDefinition": {
       "type": "object",
+      "additionalProperties": false,
       "patternProperties": {
         "^[a-zA-Z0-9_-]+$": {
           "type": "object",
diff --git a/core/assets/schemas/v1/metadata.schema.json b/core/assets/schemas/v1/metadata.schema.json
index b8e6b6119b30..5e5c753360fd 100644
--- a/core/assets/schemas/v1/metadata.schema.json
+++ b/core/assets/schemas/v1/metadata.schema.json
@@ -4,6 +4,7 @@
   "$defs": {
     "slotDefinition": {
       "type": "object",
+      "additionalProperties": false,
       "patternProperties": {
         "^[a-zA-Z0-9_-]+$": {
           "type": "object",
diff --git a/core/tests/Drupal/Tests/Core/Theme/Component/ComponentValidatorTest.php b/core/tests/Drupal/Tests/Core/Theme/Component/ComponentValidatorTest.php
index 84d87390552d..7e706edcfe0e 100644
--- a/core/tests/Drupal/Tests/Core/Theme/Component/ComponentValidatorTest.php
+++ b/core/tests/Drupal/Tests/Core/Theme/Component/ComponentValidatorTest.php
@@ -124,6 +124,19 @@ public static function dataProviderValidateDefinitionInvalid(): \Generator {
     ];
     yield 'invalid slot (type)' => [$cta_with_invalid_slot_type];
 
+    $cta_with_invalid_slot_name = $valid_cta;
+    $cta_with_invalid_slot_name['slots'] = [
+      'valid_slot' => [
+        'title' => 'Valid slot',
+        'description' => 'Valid slot description',
+      ],
+      'invalid slot' => [
+        'title' => 'Invalid slot',
+        'description' => 'Slot name cannot have spaces',
+      ],
+    ];
+    yield 'invalid slot (name with spaces)' => [$cta_with_invalid_slot_name];
+
     $cta_with_invalid_variant_title_type = $valid_cta;
     $cta_with_invalid_variant_title_type['variants'] = [
       'valid_variant' => [
-- 
GitLab