Skip to content

Commit f716ba6

Browse files
georgeolaruclaude
andcommitted
Fix Card blocks displaying raw HTML for meta text
The security escaping in 2.1.10 (commit a4f1895) applied esc_html() in novablocks_get_card_item_meta() which receives pre-built HTML from dynamic post cards. This escaped the internal <span> wrapper tags, displaying them as visible text instead of rendering them. Fix: escape text values at source in novablocks_get_post_card_meta(), escape static card attributes at call site, and use wp_kses_post() in the shared function to allow internally-generated HTML structure. Fixes #477 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 637ef12 commit f716ba6

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

lib/block-rendering.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,10 +1493,10 @@ function novablocks_get_card_contents( array $attributes ): string {
14931493

14941494
$output = '';
14951495

1496-
$output .= novablocks_get_card_item_meta( $attributes['metaAboveTitle'], $attributes );
1496+
$output .= novablocks_get_card_item_meta( esc_html( $attributes['metaAboveTitle'] ), $attributes );
14971497
$output .= novablocks_get_card_item_title( $attributes['title'], $attributes );
14981498
$output .= novablocks_get_card_item_subtitle( $attributes['subtitle'], $attributes );
1499-
$output .= novablocks_get_card_item_meta( $attributes['metaBelowTitle'], $attributes );
1499+
$output .= novablocks_get_card_item_meta( esc_html( $attributes['metaBelowTitle'] ), $attributes );
15001500
$output .= novablocks_get_card_item_description( $attributes['description'], $attributes );
15011501
$output .= novablocks_get_card_item_buttons( [
15021502
[
@@ -1514,7 +1514,7 @@ function novablocks_get_card_item_meta( $metaValue, array $attributes ): string
15141514
return '';
15151515
}
15161516

1517-
return '<p class="nb-card__meta is-style-meta">' . esc_html( $metaValue ) . '</p>';
1517+
return '<p class="nb-card__meta is-style-meta">' . wp_kses_post( $metaValue ) . '</p>';
15181518
}
15191519

15201520
function novablocks_get_card_item_title( string $title, array $attributes, $post = null ): string {
@@ -1741,7 +1741,7 @@ function novablocks_get_post_card_contents( $post, $attributes ): string {
17411741
function novablocks_get_post_card_meta( $post, $meta ) {
17421742

17431743
if ( $meta === 'author' ) {
1744-
return get_the_author_meta( 'display_name', $post->post_author );
1744+
return esc_html( get_the_author_meta( 'display_name', $post->post_author ) );
17451745
}
17461746

17471747
if ( $meta === 'category' ) {
@@ -1769,7 +1769,7 @@ function novablocks_get_post_card_meta( $post, $meta ) {
17691769

17701770
if ( ! empty( $categories ) && ! is_wp_error( $categories ) ) {
17711771
// Return only the first one.
1772-
return $categories[0]->name;
1772+
return esc_html( $categories[0]->name );
17731773
} else {
17741774
return '';
17751775
}
@@ -1827,15 +1827,15 @@ function novablocks_get_post_card_meta( $post, $meta ) {
18271827
if ( ! empty( $tags ) && ! is_wp_error( $tags ) ) {
18281828
$tag_names = array_map( 'novablocks_get_tag_name', $tags );
18291829

1830-
return join( ', ', $tag_names );
1830+
return esc_html( join( ', ', $tag_names ) );
18311831
} else {
18321832
return '';
18331833
}
18341834
}
18351835

18361836
if ( $meta == 'reading-time' ) {
18371837
/* translators: %s: The post reading time in minutes. */
1838-
return sprintf( __( '%s min read', '__plugin_txtd' ), novablocks_get_post_reading_time_in_minutes( $post ) );
1838+
return esc_html( sprintf( __( '%s min read', '__plugin_txtd' ), novablocks_get_post_reading_time_in_minutes( $post ) ) );
18391839
}
18401840

18411841
return '';

nova-blocks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: Nova Blocks
44
* Plugin URI: https://github.com/pixelgrade/nova-blocks/
55
* Description: Nova Blocks is a collection of <strong>distinctive Gutenberg blocks</strong>, committed to making your site shine like a newborn star. It is taking a design-driven approach to help you made the right decisions and showcase your content in the best shape.
6-
* Version: 2.1.10
6+
* Version: 2.1.11
77
* Author: Pixelgrade
88
* Author URI: https://www.pixelgrade.com
99
* License: GPLv2 or later

readme.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: pixelgrade, vlad.olaru, babbardel, razvanonofrei, gorby31
33
Tags: blocks, editor, gutenberg, gutenberg blocks, page builder, block enabled, page building, full site editing, site editor, posts collection
44
Requires at least: 5.9
55
Tested up to: 6.9.1
6-
Stable tag: 2.1.10
6+
Stable tag: 2.1.11
77
Requires PHP: 7.4
88
License: GPLv2 or later
99
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -94,6 +94,9 @@ Yes! Nova Block's core features are free to use.
9494

9595
== Changelog ==
9696

97+
= 2.1.11 =
98+
* Fix: Card blocks displaying raw HTML span tags for category/author/tag meta text (regression from 2.1.10 security escaping).
99+
97100
= 2.1.10 =
98101
* Security: Fixed Stored XSS in Separator block (CVE-2026-24528).
99102
* Security: Fixed Object Injection via unserialize() in author-box block.

0 commit comments

Comments
 (0)