From 9f6d28ff8d03db0c7315313580c2bfe6bf37446f Mon Sep 17 00:00:00 2001 From: Patrick Joyce Date: Wed, 24 Jul 2024 14:06:34 -0400 Subject: [PATCH] more santizining lint fix --- ossc.php | 22 +++++++++++++++------- readme.txt | 13 +++++++++++++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/ossc.php b/ossc.php index 30bed29..cb7efb2 100644 --- a/ossc.php +++ b/ossc.php @@ -173,7 +173,7 @@ public static function settings_link( array $links ): array { } private static function determine_option( string|array $attrs, string $option ): string { - if ( isset( $_POST['ossc_nonce'] ) && wp_verify_nonce( $_POST['ossc_nonce'], 'ossc_action' ) ) { + if ( isset( $_POST['ossc_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['ossc_nonce'] ) ), 'ossc_action' ) ) { if ( isset( $_POST[ $option ] ) ) { // Form data option return sanitize_text_field( strtolower( $_POST[ $option ] ) ); @@ -243,11 +243,17 @@ public function render_ossc( string|array $attrs = [] ): string { $table_name = $wpdb->prefix . 'ossc_github_data'; $content = '
'; - $github_repos = explode( ',', get_option( 'github_repos' ) ); + $github_repos_option = sanitize_textarea_field( get_option( 'github_repos' ) ) + + if ( ! empty( $github_repos_option ) ) { + $github_repos = array_map( 'trim', explode( ',', $github_repos_option ) ); + } else { + $github_repos = []; + } foreach ( $github_repos as $repo ) { $repo_name = explode( '/', $repo )[1] ?? ''; - $content .= '

' . $repo_name . '

'; + $content .= '

' . $repo_name . '

'; $results = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM %i WHERE repo = %s ORDER BY closed_at DESC', $table_name, $repo ), ARRAY_A ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $content .= '