fix: Schriftname wird vor der Katalogprüfung getrimmt (Theme-Optionen)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
2b45f1bdd3
commit
0a24753b4d
@@ -170,17 +170,17 @@ final class DiviThemeOptionsUpdateAbility implements Ability, RequiresDiviFeatur
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$problem = ThemeOptionSpec::check($key, $value);
|
$problem = ThemeOptionSpec::check($key, $value);
|
||||||
|
$normalized = $problem === null ? ThemeOptionSpec::normalize($key, $value) : null;
|
||||||
if ($problem === null && ThemeOptionSpec::definition($key)['type'] === 'font') {
|
if ($problem === null && ThemeOptionSpec::definition($key)['type'] === 'font') {
|
||||||
// Before Divi's sanitizer: it would only answer false, without suggestions.
|
// Before Divi's sanitizer: it would only answer false, without suggestions. The trimmed name is checked.
|
||||||
$problem = FontCheck::problem($this->fonts, (string) $value);
|
$problem = FontCheck::problem($this->fonts, (string) $normalized);
|
||||||
}
|
}
|
||||||
if ($problem !== null) {
|
if ($problem !== null || $normalized === null) {
|
||||||
$errors[$field] = $problem;
|
$errors[$field] = $problem ?? 'Divi lehnt den Wert ab';
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$normalized = ThemeOptionSpec::normalize($key, $value);
|
|
||||||
$sanitized = $this->options->sanitize($key, $normalized);
|
$sanitized = $this->options->sanitize($key, $normalized);
|
||||||
if (! is_int($sanitized) && ! is_float($sanitized) && ! is_string($sanitized)) {
|
if (! is_int($sanitized) && ! is_float($sanitized) && ! is_string($sanitized)) {
|
||||||
$errors[$field] = 'Divi lehnt den Wert ab';
|
$errors[$field] = 'Divi lehnt den Wert ab';
|
||||||
|
|||||||
@@ -152,6 +152,14 @@ final class DiviThemeOptionsUpdateAbilityTest extends TestCase
|
|||||||
self::assertSame(ThemeOptionBook::fromDivi($this->stored)->rev(), $result['design_rev']);
|
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). */
|
/** Only fonts reach the builder (W7). */
|
||||||
public function testSizesOnlyWarnAboutTheWholeWebsite(): void
|
public function testSizesOnlyWarnAboutTheWholeWebsite(): void
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user