From 0a24753b4d9e9796223dc8771c9ad4e5b4f012ab Mon Sep 17 00:00:00 2001 From: Jan-Niclas Loosen Date: Mon, 19 Oct 2026 18:27:16 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20Schriftname=20wird=20vor=20der=20Katalog?= =?UTF-8?q?pr=C3=BCfung=20getrimmt=20(Theme-Optionen)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5.5 --- .../Divi/Design/DiviThemeOptionsUpdateAbility.php | 10 +++++----- .../Divi/Design/DiviThemeOptionsUpdateAbilityTest.php | 8 ++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Integrations/Divi/Design/DiviThemeOptionsUpdateAbility.php b/src/Integrations/Divi/Design/DiviThemeOptionsUpdateAbility.php index ffebb23..21518c2 100644 --- a/src/Integrations/Divi/Design/DiviThemeOptionsUpdateAbility.php +++ b/src/Integrations/Divi/Design/DiviThemeOptionsUpdateAbility.php @@ -170,17 +170,17 @@ final class DiviThemeOptionsUpdateAbility implements Ability, RequiresDiviFeatur return null; } $problem = ThemeOptionSpec::check($key, $value); + $normalized = $problem === null ? ThemeOptionSpec::normalize($key, $value) : null; if ($problem === null && ThemeOptionSpec::definition($key)['type'] === 'font') { - // Before Divi's sanitizer: it would only answer false, without suggestions. - $problem = FontCheck::problem($this->fonts, (string) $value); + // Before Divi's sanitizer: it would only answer false, without suggestions. The trimmed name is checked. + $problem = FontCheck::problem($this->fonts, (string) $normalized); } - if ($problem !== null) { - $errors[$field] = $problem; + if ($problem !== null || $normalized === null) { + $errors[$field] = $problem ?? 'Divi lehnt den Wert ab'; return null; } - $normalized = ThemeOptionSpec::normalize($key, $value); $sanitized = $this->options->sanitize($key, $normalized); if (! is_int($sanitized) && ! is_float($sanitized) && ! is_string($sanitized)) { $errors[$field] = 'Divi lehnt den Wert ab'; diff --git a/tests/Unit/Integrations/Divi/Design/DiviThemeOptionsUpdateAbilityTest.php b/tests/Unit/Integrations/Divi/Design/DiviThemeOptionsUpdateAbilityTest.php index fef9be7..ae5371a 100644 --- a/tests/Unit/Integrations/Divi/Design/DiviThemeOptionsUpdateAbilityTest.php +++ b/tests/Unit/Integrations/Divi/Design/DiviThemeOptionsUpdateAbilityTest.php @@ -152,6 +152,14 @@ final class DiviThemeOptionsUpdateAbilityTest extends TestCase self::assertSame(ThemeOptionBook::fromDivi($this->stored)->rev(), $result['design_rev']); } + public function testAFontNameIsTrimmedBeforeTheCatalogCheck(): void + { + $result = $this->confirmed($this->ability(self::snapshots()), ['set' => ['heading_font' => ' Roboto']])[1]; + + self::assertSame('theme_options-1', $result['snapshot_id']); + self::assertSame('Roboto', $this->stored['heading_font']); + } + /** Only fonts reach the builder (W7). */ public function testSizesOnlyWarnAboutTheWholeWebsite(): void {