diff --git a/src/admin.php b/src/admin.php index 711a28f..f137ec8 100644 --- a/src/admin.php +++ b/src/admin.php @@ -22,8 +22,8 @@ function get_admin_tabs() { $tabs = apply_plugin_filters('admin_tabs', []); $keys = array_keys($tabs); - $active = (isset($_GET['tab']) && $_GET['tab']) ? $_GET['tab'] : reset($keys); - $active = apply_plugin_filters('active_admin_tab', $active); + $tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : reset($keys); + $active = apply_plugin_filters('active_admin_tab', $tab); return [$tabs, $active]; } diff --git a/src/ajax.php b/src/ajax.php index 2b1ab59..6c55fc0 100644 --- a/src/ajax.php +++ b/src/ajax.php @@ -36,8 +36,8 @@ function ajax() ])); } - $id = $_POST['id']; - $slug = $_POST['slug']; + $id = sanitize_text_field($_POST['id']); + $slug = sanitize_text_field($_POST['slug']); if (! apply_plugin_filters('can_vote', true, $id, $slug)) { header('Content-Type: application/json; charset=utf-8', true, 401); @@ -55,9 +55,9 @@ function ajax() ])); } - $best = $_POST['best'] ?: get_option(prefix('stars')); + $best = isset($_POST['best']) ? sanitize_text_field($_POST['best']): get_option(prefix('stars')); $best = max((int) $best, 1); - $score = $_POST['score']; + $score = sanitize_text_field($_POST['score']); $score = min(max((int) $score, 1), $best); do_plugin_action('vote', $score, $best, $id, $slug); diff --git a/src/metabox.php b/src/metabox.php index 12b1429..05269bd 100644 --- a/src/metabox.php +++ b/src/metabox.php @@ -91,7 +91,7 @@ function metabox_content($content, $post) function save_default_metabox($id) { if (isset($_POST[meta_prefix('status')])) { - update_post_meta($id, meta_prefix('status'), $_POST[meta_prefix('status')]); + update_post_meta($id, meta_prefix('status'), sanitize_text_field($_POST[meta_prefix('status')])); } if (isset($_POST[meta_prefix('reset')]) diff --git a/views/active-stars.php b/views/active-stars.php index b6a8c49..5a6d4ce 100644 --- a/views/active-stars.php +++ b/views/active-stars.php @@ -1,4 +1,4 @@ -