Skip to content

Commit 8aefdbc

Browse files
committed
phpcs & phpstan fixes
1 parent 6bc0db3 commit 8aefdbc

2 files changed

Lines changed: 15 additions & 15 deletions

File tree

classes/admin/class-page-settings.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ public function store_settings_form_options() {
193193
*/
194194
public function save_settings() {
195195
// Nonce is already checked in store_settings_form_options() which calls this method.
196-
$redirect_on_login = isset( $_POST['prpl-redirect-on-login'] )
197-
? \sanitize_text_field( \wp_unslash( $_POST['prpl-redirect-on-login'] ) )
196+
$redirect_on_login = isset( $_POST['prpl-redirect-on-login'] ) // phpcs:ignore WordPress.Security.NonceVerification.Missing
197+
? \sanitize_text_field( \wp_unslash( $_POST['prpl-redirect-on-login'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Missing
198198
: false;
199199

200200
\update_user_meta( \get_current_user_id(), 'prpl_redirect_on_login', (bool) $redirect_on_login );
@@ -207,8 +207,8 @@ public function save_settings() {
207207
*/
208208
public function save_post_types() {
209209
// Nonce is already checked in store_settings_form_options() which calls this method.
210-
$include_post_types = isset( $_POST['prpl-post-types-include'] )
211-
? \array_map( 'sanitize_text_field', \wp_unslash( $_POST['prpl-post-types-include'] ) ) // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
210+
$include_post_types = isset( $_POST['prpl-post-types-include'] ) // phpcs:ignore WordPress.Security.NonceVerification.Missing
211+
? \array_map( 'sanitize_text_field', \wp_unslash( $_POST['prpl-post-types-include'] ) ) // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
212212
// If no post types are selected, use the default post types (post and page can be deregistered).
213213
: \array_intersect( [ 'post', 'page' ], \progress_planner()->get_settings()->get_public_post_types() );
214214

tests/phpunit/test-class-security.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -473,10 +473,10 @@ public function evaluate() {
473473
};
474474

475475
// Test 1: Try to update a non-whitelisted option (should FAIL with fix).
476-
$original_admin_email = \get_option( 'admin_email' );
477-
$_POST['nonce'] = \wp_create_nonce( 'progress_planner' );
478-
$_POST['setting'] = 'admin_email'; // Not in whitelist.
479-
$_POST['value'] = 'hacker@evil.com';
476+
$original_admin_email = \get_option( 'admin_email' );
477+
$_POST['nonce'] = \wp_create_nonce( 'progress_planner' );
478+
$_POST['setting'] = 'admin_email'; // Not in whitelist.
479+
$_POST['value'] = 'hacker@evil.com';
480480
$_POST['setting_path'] = '[]';
481481

482482
\ob_start();
@@ -690,13 +690,13 @@ public function evaluate() {
690690
};
691691

692692
$critical_options = [
693-
'admin_email' => 'admin@example.com',
694-
'siteurl' => 'https://example.com',
695-
'home' => 'https://example.com',
696-
'users_can_register' => '0',
697-
'active_plugins' => [],
698-
'default_role' => 'subscriber',
699-
'wp_user_roles' => [],
693+
'admin_email' => 'admin@example.com',
694+
'siteurl' => 'https://example.com',
695+
'home' => 'https://example.com',
696+
'users_can_register' => '0',
697+
'active_plugins' => [],
698+
'default_role' => 'subscriber',
699+
'wp_user_roles' => [],
700700
];
701701

702702
foreach ( $critical_options as $option => $malicious_value ) {

0 commit comments

Comments
 (0)