Skip to content

Commit 55a5663

Browse files
Merge pull request #1162 from Codeinwp/bugfix/pro/939
refactor: generate nonce based on feed url
2 parents 602ae6b + 9eb7053 commit 55a5663

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

includes/abstract/feedzy-rss-feeds-admin-abstract.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,10 @@ public function feedzy_rss( $atts, $content = '' ) {
454454
} else {
455455
$attributes .= 'data-has_valid_cache="true"';
456456
}
457+
458+
// Add nonce based on feed url.
459+
$attributes .= 'data-nonce="' . esc_attr( wp_create_nonce( $feed_url ) ) . '"';
460+
457461
$class = array_filter( apply_filters( 'feedzy_add_classes_block', array( $sc['classname'], 'feedzy-' . md5( is_array( $feed_url ) ? implode( ',', $feed_url ) : $feed_url ) ), $sc, null, $feed_url ) );
458462
$html = "<div class='feedzy-lazy' $attributes>";
459463
$html .= "$content</div>";
@@ -552,6 +556,11 @@ public function feedzy_lazy_load( $data ) {
552556
$atts = $data['args'];
553557
$sc = $this->get_short_code_attributes( $atts );
554558
$feed_url = $this->normalize_urls( $sc['feeds'] );
559+
$nonce = isset( $atts['nonce'] ) ? $atts['nonce'] : '';
560+
561+
if ( ! wp_verify_nonce( $nonce, $feed_url ) ) {
562+
wp_send_json_error( array( 'message' => __( 'Security check failed.', 'feedzy-rss-feeds' ) ) );
563+
}
555564

556565
if ( isset( $sc['filters'] ) && ! empty( $sc['filters'] ) && feedzy_is_pro() ) {
557566
$sc['filters'] = apply_filters( 'feedzy_filter_conditions_attribute', $sc['filters'] );

js/feedzy-lazy.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
success: function(data){
4141
if(data.success){
4242
$feedzy_block.empty().append(data.data.content);
43+
} else {
44+
$feedzy_block.empty().append(data.data.message);
4345
}
4446
},
4547
complete: function(){

0 commit comments

Comments
 (0)