Skip to content

Commit 311cf03

Browse files
committed
Add a cap check before previewing classification of a post.
1 parent 85af4af commit 311cf03

File tree

1 file changed

+4
-1
lines changed
  • includes/Classifai/Providers/Watson

1 file changed

+4
-1
lines changed

includes/Classifai/Providers/Watson/NLU.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,10 @@ public function get_post_classifier_preview_data() {
250250
wp_send_json_error( esc_html__( 'Failed nonce check.', 'classifai' ) );
251251
}
252252

253-
$post_id = filter_input( INPUT_POST, 'post_id', FILTER_SANITIZE_NUMBER_INT );
253+
$post_id = filter_input( INPUT_POST, 'post_id', FILTER_SANITIZE_NUMBER_INT );
254+
if ( ! current_user_can( 'read_post', $post_id ) ) {
255+
wp_send_json_error( esc_html__( 'You do not have permission to preview this post.', 'classifai' ) );
256+
}
254257
$classifier = new Classifier();
255258
$normalizer = new \Classifai\Normalizer();
256259

0 commit comments

Comments
 (0)