fix(audit L1): queryType null fällt wie bei Divi (isset) auf post_types zurück; Skalare lesen wie sanitize_key
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
f754772beb
commit
6e84138979
@@ -181,14 +181,15 @@ final class ValueCleaner
|
||||
return;
|
||||
}
|
||||
// Divi reads enable and queryType through sanitize_key() (LoopUtils.php:725-731): stored values count so.
|
||||
$key = static fn (mixed $value): string => is_string($value)
|
||||
? (string) preg_replace('/[^a-z0-9_\-]/', '', strtolower($value))
|
||||
$key = static fn (mixed $value): string => is_scalar($value)
|
||||
? (string) preg_replace('/[^a-z0-9_\-]/', '', strtolower((string) $value))
|
||||
: '';
|
||||
if ($key($desktopValue['enable'] ?? null) !== 'on') {
|
||||
return;
|
||||
}
|
||||
|
||||
$queryType = array_key_exists('queryType', $desktopValue) ? $key($desktopValue['queryType']) : 'post_types';
|
||||
// isset() like Divi: null falls back to post_types.
|
||||
$queryType = isset($desktopValue['queryType']) ? $key($desktopValue['queryType']) : 'post_types';
|
||||
if (($queryType === 'user_roles' || $queryType === 'users') && ! $this->sanitizer->canListUsers()) {
|
||||
throw new InvalidArgumentException(
|
||||
'Eine Benutzer-Schleife listet Konten und E-Mail-Adressen und braucht das Recht list_users; '
|
||||
|
||||
@@ -40,6 +40,8 @@ final class ValueCleanerTest extends TestCase
|
||||
'attachment among others' => [$post + ['subTypes' => $types('post', 'attachment')]],
|
||||
'only unknown types (Divi falls back to any)' => [$post + ['subTypes' => $types('gibtesnicht')]],
|
||||
'comma string with any' => [$post + ['subTypes' => 'post, ANY']],
|
||||
'queryType null (isset: post_types), no subTypes' => [['enable' => 'on', 'queryType' => null]],
|
||||
'subTypes null' => [$post + ['subTypes' => null]],
|
||||
'entries without value' => [$post + ['subTypes' => [['label' => 'x']]]],
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user