Skip to content

Commit 144398d

Browse files
committed
more escaping
1 parent 170b9c2 commit 144398d

4 files changed

Lines changed: 16 additions & 5 deletions

File tree

assets/js/settings.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ jQuery( function( $ ) {
9292
getData: function ( type, cb ) {
9393
var payload = {
9494
action: 'aal_get_properties',
95-
action_category: type
95+
action_category: type,
96+
_nonce: window.aalSettings && window.aalSettings.nonce ? window.aalSettings.nonce : ''
9697
};
9798
$.getJSON( window.ajaxurl, payload, cb );
9899
}

classes/class-aal-admin-ui.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ public function create_admin_menu() {
2121

2222
public function activity_log_page_func() {
2323
$this->get_list_table()->prepare_items();
24+
$page_slug = isset( $_REQUEST['page'] ) ? sanitize_key( wp_unslash( $_REQUEST['page'] ) ) : 'activity-log-page';
2425
?>
2526
<div class="wrap">
2627
<h1 class="aal-page-title"><?php echo esc_html_x( 'Activity Log', 'Page and Menu Title', 'aryo-activity-log' ); ?></h1>
2728

2829
<form id="activity-filter" method="get">
29-
<input type="hidden" name="page" value="<?php echo esc_attr( $_REQUEST['page'] ); ?>" />
30+
<input type="hidden" name="page" value="<?php echo esc_attr( $page_slug ); ?>" />
3031
<?php $this->get_list_table()->display(); ?>
3132
</form>
3233
</div>

classes/class-aal-api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ protected function _get_ip_address() {
7575

7676
$visitor_ip_address = '';
7777
if ( ! empty( $_SERVER[ $header_key ] ) ) {
78-
$visitor_ip_address = $_SERVER[ $header_key ];
78+
$visitor_ip_address = sanitize_text_field( wp_unslash( $_SERVER[ $header_key ] ) );
7979
}
8080

8181
$remote_address = apply_filters( 'aal_get_ip_address', $visitor_ip_address );

classes/class-aal-settings.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ public function action_admin_menu() {
6060
*/
6161
public function scripts_n_styles() {
6262
wp_enqueue_script( 'aal-settings', plugins_url( 'assets/js/settings.js', ACTIVITY_LOG__FILE__ ), array( 'jquery' ) );
63+
wp_localize_script(
64+
'aal-settings',
65+
'aalSettings',
66+
array(
67+
'nonce' => wp_create_nonce( 'aal_get_properties' ),
68+
)
69+
);
6370
wp_enqueue_style( 'aal-settings', plugins_url( 'assets/css/settings.css', ACTIVITY_LOG__FILE__ ) );
6471
}
6572

@@ -351,11 +358,13 @@ public function ajax_aal_reset_items() {
351358
}
352359

353360
public function ajax_aal_get_properties() {
354-
if ( ! current_user_can( 'manage_options' ) ) {
361+
if ( ! check_ajax_referer( 'aal_get_properties', '_nonce', false ) || ! current_user_can( 'manage_options' ) ) {
355362
wp_send_json_error();
356363
}
357364

358-
$action_category = isset( $_REQUEST['action_category'] ) ? $_REQUEST['action_category'] : false;
365+
$action_category = isset( $_REQUEST['action_category'] )
366+
? sanitize_key( wp_unslash( $_REQUEST['action_category'] ) )
367+
: '';
359368

360369
$options = AAL_Main::instance()->notifications->get_settings_dropdown_values( $action_category );
361370

0 commit comments

Comments
 (0)