Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/bnm-blocks/bnm-blocks.php
+++ b/bnm-blocks/bnm-blocks.php
@@ -4,7 +4,7 @@
* Description: Post grid, post list, and post slider Gutenberg blocks to design blog and magazine layouts easily.
* Requires at least: 6.0
* Requires PHP: 7.0
- * Version: 1.3.0
+ * Version: 1.3.1
* Author: ThemezHut
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
--- a/bnm-blocks/src/blocks/posts/featured-posts-1/view.php
+++ b/bnm-blocks/src/blocks/posts/featured-posts-1/view.php
@@ -26,17 +26,18 @@
$featured_image_slug = ! empty( $attributes['featuredImageSizeSlug'] ) ? $attributes['featuredImageSizeSlug'] : '';
$featured_image_slug_small = ! empty( $attributes['featuredImageSizeSlugSmall'] ) ? $attributes['featuredImageSizeSlugSmall'] : '';
+ $allowed_tags = bnmbt_get_allowed_header_tags();
+ $header_html_tag = isset( $attributes['headerHtmlTag'] ) && in_array( strtolower( $attributes['headerHtmlTag'] ), $allowed_tags, true ) ? strtolower( $attributes['headerHtmlTag'] ) : 'h2';
+
ob_start();
if ( '' !== $attributes['sectionHeader'] && true === $attributes['showSectionHeader'] ) {
- echo "<div class="bnm-block-title-wrap">";
- $allowed_tags = bnmbt_get_allowed_header_tags();
- $tag = isset( $attributes['headerHtmlTag'] ) && in_array( strtolower( $attributes['headerHtmlTag'] ), $allowed_tags, true ) ? strtolower( $attributes['headerHtmlTag'] ) : 'h2';
- echo "<". esc_attr($tag) ." class="article-section-title">";
+ echo "<div class="bnm-block-title-wrap">";
+ echo "<". esc_attr($header_html_tag) ." class="article-section-title">";
echo "<span>";
echo wp_kses_post( $attributes['sectionHeader'] );
echo "</span>";
- echo "</".esc_attr($tag).">";
+ echo "</".esc_attr($header_html_tag).">";
echo "</div>";
}
@@ -220,7 +221,7 @@
}
if ( $attributes['sectionHeaderStyle'] ) {
- $classes[] = 'bnm-bhs-' . $attributes['sectionHeaderStyle'];
+ $classes[] = sanitize_html_class( 'bnm-bhs-' . $attributes['sectionHeaderStyle'] );
}
$wrapper_attributes = get_block_wrapper_attributes( array(
--- a/bnm-blocks/src/blocks/posts/featured-posts-2/view.php
+++ b/bnm-blocks/src/blocks/posts/featured-posts-2/view.php
@@ -217,7 +217,7 @@
}
if ( $attributes['sectionHeaderStyle'] ) {
- $classes[] = 'bnm-bhs-' . $attributes['sectionHeaderStyle'];
+ $classes[] = sanitize_html_class( 'bnm-bhs-' . $attributes['sectionHeaderStyle'] );
}
$wrapper_attributes = get_block_wrapper_attributes( array(
--- a/bnm-blocks/src/blocks/posts/post-block-1/view.php
+++ b/bnm-blocks/src/blocks/posts/post-block-1/view.php
@@ -27,17 +27,19 @@
$featured_image_slug = ! empty( $attributes['featuredImageSizeSlug'] ) ? $attributes['featuredImageSizeSlug'] : 'bnm-featured';
$featured_image_slug_small = ! empty( $attributes['featuredImageSizeSlugSmall'] ) ? $attributes['featuredImageSizeSlugSmall'] : 'bnm-featured-thumb';
+ $allowed_tags = bnmbt_get_allowed_header_tags();
+ $header_html_tag = isset( $attributes['headerHtmlTag'] ) && in_array( strtolower( $attributes['headerHtmlTag'] ), $allowed_tags, true ) ? strtolower( $attributes['headerHtmlTag'] ) : 'h2';
+ $title_html_tag = isset( $attributes['titleHtmlTag'] ) && in_array( strtolower( $attributes['titleHtmlTag'] ), $allowed_tags, true ) ? strtolower( $attributes['titleHtmlTag'] ) : 'h3';
+
ob_start();
if ( '' !== $attributes['sectionHeader'] && true === $attributes['showSectionHeader'] ) {
- echo "<div class="bnm-block-title-wrap">";
- $allowed_tags = bnmbt_get_allowed_header_tags();
- $tag = isset( $attributes['headerHtmlTag'] ) && in_array( strtolower( $attributes['headerHtmlTag'] ), $allowed_tags, true ) ? strtolower( $attributes['headerHtmlTag'] ) : 'h2';
- echo "<". esc_attr($tag) ." class="article-section-title">";
+ echo "<div class="bnm-block-title-wrap">";
+ echo "<". esc_attr($header_html_tag) ." class="article-section-title">";
echo "<span>";
echo wp_kses_post( $attributes['sectionHeader'] );
echo "</span>";
- echo "</".esc_attr($tag).">";
+ echo "</".esc_attr($header_html_tag).">";
echo "</div>";
}
@@ -75,16 +77,14 @@
<?php
if ( $attributes['showTitle'] ) {
- $allowed_tags = bnmbt_get_allowed_header_tags();
- $tag = isset( $attributes['titleHtmlTag'] ) && in_array( strtolower( $attributes['titleHtmlTag'] ), $allowed_tags, true ) ? strtolower( $attributes['titleHtmlTag'] ) : 'h3';
- echo "<". esc_attr($tag) ." class="entry-title">";
+ echo "<". esc_attr($title_html_tag) ." class="entry-title">";
?>
<a href="<?php echo esc_url( get_permalink() ); ?>" rel="bookmark">
<?php the_title(); ?>
</a>
<?php
- echo "</".esc_attr($tag).">";
+ echo "</".esc_attr($title_html_tag).">";
}
?>
@@ -149,16 +149,14 @@
<?php
if ( $attributes['showTitle'] ) {
- $allowed_tags = bnmbt_get_allowed_header_tags();
- $tag = isset( $attributes['titleHtmlTag'] ) && in_array( strtolower( $attributes['titleHtmlTag'] ), $allowed_tags, true ) ? strtolower( $attributes['titleHtmlTag'] ) : 'h3';
- echo "<". esc_attr($tag) ." class="entry-title">";
+ echo "<". esc_attr($title_html_tag) ." class="entry-title">";
?>
<a href="<?php echo esc_url( get_permalink() ); ?>" rel="bookmark">
<?php the_title(); ?>
</a>
<?php
- echo "</".esc_attr($tag).">";
+ echo "</".esc_attr($title_html_tag).">";
}
?>
@@ -236,7 +234,7 @@
}
if ( $attributes['sectionHeaderStyle'] ) {
- $classes[] = 'bnm-bhs-' . $attributes['sectionHeaderStyle'];
+ $classes[] = sanitize_html_class( 'bnm-bhs-' . $attributes['sectionHeaderStyle'] );
}
$wrapper_attributes = get_block_wrapper_attributes( array(
--- a/bnm-blocks/src/blocks/posts/post-block-2/view.php
+++ b/bnm-blocks/src/blocks/posts/post-block-2/view.php
@@ -27,20 +27,21 @@
$featured_image_slug = ! empty( $attributes['featuredImageSizeSlug'] ) ? $attributes['featuredImageSizeSlug'] : 'bnm-featured';
$featured_image_slug_small = ! empty( $attributes['featuredImageSizeSlugSmall'] ) ? $attributes['featuredImageSizeSlugSmall'] : 'bnm-featured-thumb';
+ $allowed_tags = bnmbt_get_allowed_header_tags();
+ $header_html_tag = isset( $attributes['headerHtmlTag'] ) && in_array( strtolower( $attributes['headerHtmlTag'] ), $allowed_tags, true ) ? strtolower( $attributes['headerHtmlTag'] ) : 'h2';
+
ob_start();
?>
<div class="posts-block-2-container">
<?php
if ( '' !== $attributes['sectionHeader'] && true === $attributes['showSectionHeader'] ) {
- echo "<div class="bnm-block-title-wrap">";
- $allowed_tags = bnmbt_get_allowed_header_tags();
- $tag = isset( $attributes['headerHtmlTag'] ) && in_array( strtolower( $attributes['headerHtmlTag'] ), $allowed_tags, true ) ? strtolower( $attributes['headerHtmlTag'] ) : 'h2';
- echo "<". esc_attr($tag) ." class="article-section-title">";
+ echo "<div class="bnm-block-title-wrap">";
+ echo "<". esc_attr($header_html_tag) ." class="article-section-title">";
echo "<span>";
echo wp_kses_post( $attributes['sectionHeader'] );
echo "</span>";
- echo "</".esc_attr($tag).">";
+ echo "</".esc_attr($header_html_tag).">";
echo "</div>";
}
?>
@@ -212,7 +213,7 @@
}
if ( $attributes['sectionHeaderStyle'] ) {
- $classes[] = 'bnm-bhs-' . $attributes['sectionHeaderStyle'];
+ $classes[] = sanitize_html_class( 'bnm-bhs-' . $attributes['sectionHeaderStyle'] );
}
$wrapper_attributes = get_block_wrapper_attributes( array(
--- a/bnm-blocks/src/blocks/posts/posts-ultra/view.php
+++ b/bnm-blocks/src/blocks/posts/posts-ultra/view.php
@@ -23,6 +23,14 @@
$article_query = new WP_Query( $post_query_args );
+ $show_featured_image = $attributes[ 'showFeaturedImage' ];
+ $image_position = $attributes[ 'imagePosition' ];
+ $image_min_height = isset( $attributes[ 'imageMinHeight' ] ) ? (float) $attributes[ 'imageMinHeight' ] : 0;
+
+ $allowed_tags = bnmbt_get_allowed_header_tags();
+ $title_html_tag = isset( $attributes['titleHtmlTag'] ) && in_array( strtolower( $attributes['titleHtmlTag'] ), $allowed_tags, true ) ? strtolower( $attributes['titleHtmlTag'] ) : 'h3';
+ $header_html_tag = isset( $attributes['headerHtmlTag'] ) && in_array( strtolower( $attributes['headerHtmlTag'] ), $allowed_tags, true ) ? strtolower( $attributes['headerHtmlTag'] ) : 'h2';
+
ob_start();
?>
@@ -30,14 +38,12 @@
<?php
if ( '' !== $attributes['sectionHeader'] && true === $attributes['showSectionHeader'] ) {
- echo "<div class="bnm-block-title-wrap">";
- $allowed_tags = bnmbt_get_allowed_header_tags();
- $tag = isset( $attributes['headerHtmlTag'] ) && in_array( strtolower( $attributes['headerHtmlTag'] ), $allowed_tags, true ) ? strtolower( $attributes['headerHtmlTag'] ) : 'h2';
- echo "<". esc_attr($tag) ." class="article-section-title">";
+ echo "<div class="bnm-block-title-wrap">";
+ echo "<". esc_attr($header_html_tag) ." class="article-section-title">";
echo "<span>";
echo wp_kses_post( $attributes['sectionHeader'] );
echo "</span>";
- echo "</".esc_attr($tag).">";
+ echo "</".esc_attr($header_html_tag).">";
echo "</div>";
}
@@ -50,7 +56,6 @@
$post_classes = 'bnmsp-post';
$has_post_thumbnail = has_post_thumbnail();
- $show_featured_image = $attributes[ 'showFeaturedImage' ];
if ( $show_featured_image && $has_post_thumbnail ) {
$post_classes .= ' post-has-image';
@@ -58,13 +63,9 @@
$article_styles = '';
- if ( "behind" === $attributes[ 'imagePosition' ] && $show_featured_image && $has_post_thumbnail ) {
- $article_styles .= "min-height: ". $attributes[ 'imageMinHeight' ] ."vh;";
- }
-
- if ( "behind" === $attributes[ 'imagePosition' ] && $show_featured_image && $has_post_thumbnail ) {
- $padding_top = $attributes[ 'imageMinHeight' ] / 5;
- $article_styles .= " padding-top: ". $padding_top ."vh;";
+ if ( "behind" === $image_position && $show_featured_image && $has_post_thumbnail ) {
+ $article_styles .= "min-height: {$image_min_height}vh;";
+ $article_styles .= "padding-top: " . ( $image_min_height / 5 ) . "vh;";
}
?>
@@ -87,17 +88,15 @@
<?php } ?>
<?php
- if ( $attributes['showTitle'] ) {
- $allowed_tags = bnmbt_get_allowed_header_tags();
- $tag = isset( $attributes['titleHtmlTag'] ) && in_array( strtolower( $attributes['titleHtmlTag'] ), $allowed_tags, true ) ? strtolower( $attributes['titleHtmlTag'] ) : 'h3';
- echo "<". esc_attr($tag) ." class="entry-title">";
+ if ( $attributes['showTitle'] ) {
+ echo "<". esc_attr($title_html_tag) ." class="entry-title">";
?>
<a href="<?php echo esc_url( get_permalink() ); ?>" rel="bookmark">
<?php the_title(); ?>
</a>
<?php
- echo "</".esc_attr($tag).">";
+ echo "</".esc_attr($title_html_tag).">";
}
?>
@@ -171,15 +170,15 @@
}
if ( isset( $attributes['columns'] ) && 'grid' === $attributes['postLayout'] ) {
- $classes[] = 'columns-' . $attributes['columns'];
+ $classes[] = sanitize_html_class( 'columns-' . $attributes['columns'] );
}
- if ( $attributes['showFeaturedImage'] && isset( $attributes['imagePosition'] ) ) {
- $classes[] = 'image-align' . $attributes['imagePosition'];
+ if ( $show_featured_image && isset( $image_position ) ) {
+ $classes[] = sanitize_html_class( 'image-align' . $image_position );
}
if ( $attributes['textAlign'] ) {
- $classes[] = 'has-text-align' . $attributes['textAlign'];
+ $classes[] = sanitize_html_class( 'has-text-align' . $attributes['textAlign'] );
}
if ( "33%" !== $attributes['featuredImageWidth'] || "67%" !== $attributes['entryContentWidth'] ) {
@@ -191,7 +190,7 @@
}
if ( $attributes['sectionHeaderStyle'] ) {
- $classes[] = 'bnm-bhs-' . $attributes['sectionHeaderStyle'];
+ $classes[] = sanitize_html_class( 'bnm-bhs-' . $attributes['sectionHeaderStyle'] );
}
if ( ! empty( $attributes['featuredImageMargin'] ) ) {
--- a/bnm-blocks/src/blocks/posts/slider/view.php
+++ b/bnm-blocks/src/blocks/posts/slider/view.php
@@ -34,28 +34,30 @@
$article_query = new WP_Query( $post_query_args );
$slider_style = isset( $attributes['sliderStyle'] ) ? $attributes['sliderStyle'] : 'style-1';
- $slides_per_view = isset( $attributes['slidesPerView'] ) ? $attributes['slidesPerView'] : 1;
- $asepec_ratio = isset( $attributes['aspectRatio'] ) ? $attributes['aspectRatio'] : 0.5625;
- $space_between_slides = isset( $attributes['spaceBetweenSlides'] ) ? $attributes['spaceBetweenSlides'] : 20;
- $autoplay = isset( $attributes['autoplay'] ) ? $attributes['autoplay'] : false;
+ $slides_per_view = isset( $attributes['slidesPerView'] ) ? (int) $attributes['slidesPerView'] : 1;
+ $asepect_ratio = isset( $attributes['aspectRatio'] ) ? (float) $attributes['aspectRatio'] : 0.5625;
+ $space_between_slides = isset( $attributes['spaceBetweenSlides'] ) ? (int) $attributes['spaceBetweenSlides'] : 20;
+ $autoplay = isset( $attributes['autoplay'] ) ? (bool) $attributes['autoplay'] : false;
$delay = isset( $attributes['delay'] ) ? absint( $attributes['delay'] ) : 5;
$featured_image_slug = ! empty( $attributes['featuredImageSizeSlug'] ) ? $attributes['featuredImageSizeSlug'] : '';
$slider_thumb_size = ! empty( $attributes['slideThumbSize'] ) ? $attributes['slideThumbSize'] : '';
$image_fit = ! empty( $attributes['imageFit'] ) ? $attributes['imageFit'] : 'cover';
- $thumbSlidesPerView = isset( $attributes['thumbSlidesPerView'] ) ? $attributes['thumbSlidesPerView'] : 5;
- $slide_image_class = "image-fit-{$image_fit}";
+ $thumbSlidesPerView = isset( $attributes['thumbSlidesPerView'] ) ? (int) $attributes['thumbSlidesPerView'] : 5;
+ $slide_image_class = sanitize_html_class( 'image-fit-'. $image_fit );
+
+ $allowed_tags = bnmbt_get_allowed_header_tags();
+ $header_html_tag = isset( $attributes['headerHtmlTag'] ) && in_array( strtolower( $attributes['headerHtmlTag'] ), $allowed_tags, true ) ? strtolower( $attributes['headerHtmlTag'] ) : 'h2';
+ $title_html_tag = isset( $attributes['titleHtmlTag'] ) && in_array( strtolower( $attributes['titleHtmlTag'] ), $allowed_tags, true ) ? strtolower( $attributes['titleHtmlTag'] ) : 'h3';
ob_start();
if ( '' !== $attributes['sectionHeader'] && true === $attributes['showSectionHeader'] ) {
- echo "<div class="bnm-block-title-wrap">";
- $allowed_tags = bnmbt_get_allowed_header_tags();
- $tag = isset( $attributes['headerHtmlTag'] ) && in_array( strtolower( $attributes['headerHtmlTag'] ), $allowed_tags, true ) ? strtolower( $attributes['headerHtmlTag'] ) : 'h2';
- echo "<". esc_attr($tag) ." class="article-section-title">";
+ echo "<div class="bnm-block-title-wrap">";
+ echo "<". esc_attr($header_html_tag) ." class="article-section-title">";
echo "<span>";
echo wp_kses_post( $attributes['sectionHeader'] );
echo "</span>";
- echo "</".esc_attr($tag).">";
+ echo "</".esc_attr($header_html_tag).">";
echo "</div>";
}
@@ -101,17 +103,15 @@
</div>
<?php endif; ?>
- <?php if ( $attributes['showTitle'] ) {
- $allowed_tags = bnmbt_get_allowed_header_tags();
- $tag = isset( $attributes['titleHtmlTag'] ) && in_array( strtolower( $attributes['titleHtmlTag'] ), $allowed_tags, true ) ? strtolower( $attributes['titleHtmlTag'] ) : 'h3';
- echo "<". esc_attr($tag) ." class="entry-title">";
+ <?php if ( $attributes['showTitle'] ) {
+ echo "<". esc_attr($title_html_tag) ." class="entry-title">";
?>
<a href="<?php echo esc_url( get_permalink() ); ?>" rel="bookmark">
<?php the_title(); ?>
</a>
<?php
- echo "</".esc_attr($tag).">";
+ echo "</".esc_attr($title_html_tag).">";
}
?>
@@ -165,7 +165,7 @@
</div><!-- .bnm-slider-wrapper -->
- <?php if ( $attributes['sliderStyle'] === 'style-4' ) : ?>
+ <?php if ( $slider_style === 'style-4' ) : ?>
<div thumbsSlider="" class="bnm-thumbnail-swiper swiper">
<div class="swiper-wrapper">
<?php
@@ -213,7 +213,7 @@
$slider_block = ob_get_clean();
// Slider style class name.
- $slider_style_class = 'bnm-sw-' . $attributes['sliderStyle'];
+ $slider_style_class = sanitize_html_class( 'bnm-sw-' . $slider_style );
$classes = array( 'wpbnmposw', 'bnmbcs', $slider_style_class );
@@ -222,7 +222,7 @@
}
if ( $attributes['sectionHeaderStyle'] ) {
- $classes[] = 'bnm-bhs-' . $attributes['sectionHeaderStyle'];
+ $classes[] = sanitize_html_class( 'bnm-bhs-' . $attributes['sectionHeaderStyle'] );
}
$css = new Post_Slider_1_CSS();
@@ -235,21 +235,24 @@
$data_attributes = [
//'data-current-post-id=' . $post_id,
- 'data-slider-style=' . $slider_style,
- 'data-aspect-ratio=' . $asepec_ratio,
- 'data-slides-per-view=' . $slides_per_view,
- 'data-space-between-slides=' . $space_between_slides,
- 'data-thumb-slides-per-view=' . $thumbSlidesPerView
+ 'data-slider-style="' . esc_attr( $slider_style ) . '"',
+ 'data-aspect-ratio="' . esc_attr( $asepect_ratio ) . '"',
+ 'data-slides-per-view="' . esc_attr( $slides_per_view ) . '"',
+ 'data-space-between-slides="' . esc_attr( $space_between_slides ) . '"',
+ 'data-thumb-slides-per-view="' . esc_attr( $thumbSlidesPerView ) . '"'
];
if ( $autoplay ) {
- $data_attributes[] = 'data-autoplay=1';
- $data_attributes[] = sprintf( 'data-autoplay_delay=%s', esc_attr( $delay ) );
+ $data_attributes[] = 'data-autoplay="1"';
+ $data_attributes[] = sprintf(
+ 'data-autoplay_delay="%s"',
+ esc_attr( $delay )
+ );
}
return sprintf( '<div %1$s %2$s>%3$s</div>',
$wrapper_attributes,
- esc_attr( implode( ' ', $data_attributes ) ),
+ implode( ' ', $data_attributes ),
$slider_block
);
}
No newline at end of file