Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/otter-blocks/build/animation/frontend.asset.php
+++ b/otter-blocks/build/animation/frontend.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array(), 'version' => '85c87361b4be0dc88708');
+<?php return array('dependencies' => array(), 'version' => 'c44084e33dc17a73066a');
--- a/otter-blocks/build/blocks/blocks.asset.php
+++ b/otter-blocks/build/blocks/blocks.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'moment', 'react', 'react-dom', 'react-jsx-runtime', 'wp-api', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-edit-post', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-keycodes', 'wp-plugins', 'wp-primitives', 'wp-rich-text', 'wp-server-side-render', 'wp-url'), 'version' => '1f3cd78557ad425c7930');
+<?php return array('dependencies' => array('lodash', 'moment', 'react', 'react-dom', 'react-jsx-runtime', 'wp-api', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-edit-post', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-keycodes', 'wp-plugins', 'wp-primitives', 'wp-rich-text', 'wp-server-side-render', 'wp-url'), 'version' => '20ce5cad211d8091741a');
--- a/otter-blocks/build/blocks/form.asset.php
+++ b/otter-blocks/build/blocks/form.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array(), 'version' => '9135d80b9976657ad67b');
+<?php return array('dependencies' => array(), 'version' => '27b26b0b78d87efb81b4');
--- a/otter-blocks/build/blocks/tabs.asset.php
+++ b/otter-blocks/build/blocks/tabs.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array(), 'version' => '4bc41bcd5550058f5a3d');
+<?php return array('dependencies' => array(), 'version' => '7f25dee0438b96b3a1f7');
--- a/otter-blocks/inc/class-main.php
+++ b/otter-blocks/inc/class-main.php
@@ -30,7 +30,7 @@
*/
public function init() {
if ( ! defined( 'THEMEISLE_BLOCKS_VERSION' ) ) {
- define( 'THEMEISLE_BLOCKS_VERSION', '3.1.4' );
+ define( 'THEMEISLE_BLOCKS_VERSION', '3.1.5' );
}
add_action( 'init', array( $this, 'autoload_classes' ), 9 );
--- a/otter-blocks/inc/class-registration.php
+++ b/otter-blocks/inc/class-registration.php
@@ -386,7 +386,7 @@
}
- if ( function_exists( 'get_block_templates' ) && function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() && current_theme_supports( 'block-templates' ) ) {
+ if ( function_exists( 'get_block_templates' ) && ( current_theme_supports( 'block-templates' ) || current_theme_supports( 'block-template-parts' ) ) ) {
$this->enqueue_dependencies( 'block-templates' );
}
}
@@ -406,25 +406,42 @@
} elseif ( 'block-templates' === $post ) {
global $_wp_current_template_content;
- $slugs = array();
- $template_blocks = parse_blocks( $_wp_current_template_content );
+ $content = '';
+ $slugs = array();
- foreach ( $template_blocks as $template_block ) {
- if ( 'core/template-part' === $template_block['blockName'] ) {
- $slugs[] = $template_block['attrs']['slug'];
+ // If we have template content (full block templates), extract template part slugs.
+ if ( ! empty( $_wp_current_template_content ) ) {
+ $template_blocks = parse_blocks( $_wp_current_template_content );
+
+ foreach ( $template_blocks as $template_block ) {
+ if ( 'core/template-part' === $template_block['blockName'] && isset( $template_block['attrs']['slug'] ) ) {
+ $slugs[] = $template_block['attrs']['slug'];
+ }
}
- }
-
- $templates_parts = get_block_templates( array( 'slugs__in' => $slugs ), 'wp_template_part' );
-
- foreach ( $templates_parts as $templates_part ) {
- if ( ! empty( $templates_part->content ) && ! empty( $templates_part->slug ) && in_array( $templates_part->slug, $slugs ) ) {
- $content .= $templates_part->content;
+
+ // Get the specific template parts referenced in the template.
+ $templates_parts = get_block_templates( array( 'slug__in' => $slugs ), 'wp_template_part' );
+
+ foreach ( $templates_parts as $templates_part ) {
+ if ( ! empty( $templates_part->content ) && ! empty( $templates_part->slug ) && in_array( $templates_part->slug, $slugs ) ) {
+ $content .= $templates_part->content;
+ }
+ }
+
+ $content .= $_wp_current_template_content;
+ } else {
+ // Fallback for classic themes with block-template-parts only.
+ // Get all template parts since we can't determine which ones are used.
+ $templates_parts = get_block_templates( array(), 'wp_template_part' );
+
+ foreach ( $templates_parts as $templates_part ) {
+ if ( ! empty( $templates_part->content ) ) {
+ $content .= $templates_part->content;
+ }
}
}
- $content .= $_wp_current_template_content;
- $post = $content;
+ $post = $content;
} else {
$content = get_the_content( null, false, $post );
}
@@ -1065,7 +1082,7 @@
* @access public
*/
public static function condition_hide_on_style() {
- echo '<style id="o-condition-hide-inline-css">@media (max-width:768px){.o-hide-on-mobile{display:none!important}}@media (min-width:767px) and (max-width:1024px){.o-hide-on-tablet{display:none!important}}@media (min-width:1023px){.o-hide-on-desktop{display:none!important}}</style>';
+ echo '<style id="o-condition-hide-inline-css">@media (max-width:768px){.o-hide-on-mobile{display:none!important}}@media (min-width:769px) and (max-width:1024px){.o-hide-on-tablet{display:none!important}}@media (min-width:1025px){.o-hide-on-desktop{display:none!important}}</style>';
}
/**
--- a/otter-blocks/inc/css/class-block-frontend.php
+++ b/otter-blocks/inc/css/class-block-frontend.php
@@ -577,32 +577,47 @@
* @access public
*/
public function enqueue_fse_css() {
- if ( ! ( function_exists( 'get_block_templates' ) && function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() && current_theme_supports( 'block-templates' ) ) ) {
+ if ( ! ( function_exists( 'get_block_templates' ) && ( current_theme_supports( 'block-templates' ) || current_theme_supports( 'block-template-parts' ) ) ) ) {
return;
}
global $_wp_current_template_content;
- $content = '';
- $slugs = array();
- $template_blocks = parse_blocks( $_wp_current_template_content );
+ $content = '';
+ $slugs = array();
- foreach ( $template_blocks as $template_block ) {
- if ( 'core/template-part' === $template_block['blockName'] ) {
- $slugs[] = $template_block['attrs']['slug'];
+ // If we have template content (full block templates), extract template part slugs.
+ if ( ! empty( $_wp_current_template_content ) ) {
+ $template_blocks = parse_blocks( $_wp_current_template_content );
+
+ foreach ( $template_blocks as $template_block ) {
+ if ( 'core/template-part' === $template_block['blockName'] && isset( $template_block['attrs']['slug'] ) ) {
+ $slugs[] = $template_block['attrs']['slug'];
+ }
}
- }
-
- $templates_parts = get_block_templates( array( 'slugs__in' => $slugs ), 'wp_template_part' );
-
- foreach ( $templates_parts as $templates_part ) {
- if ( ! empty( $templates_part->content ) && ! empty( $templates_part->slug ) && in_array( $templates_part->slug, $slugs ) ) {
- $content .= $templates_part->content;
+
+ // Get the specific template parts referenced in the template.
+ $templates_parts = get_block_templates( array( 'slug__in' => $slugs ), 'wp_template_part' );
+
+ foreach ( $templates_parts as $templates_part ) {
+ if ( ! empty( $templates_part->content ) && ! empty( $templates_part->slug ) && in_array( $templates_part->slug, $slugs ) ) {
+ $content .= $templates_part->content;
+ }
+ }
+
+ $content .= $_wp_current_template_content;
+ } else {
+ // Fallback for classic themes with block-template-parts only.
+ // Get all template parts since we can't determine which ones are used.
+ $templates_parts = get_block_templates( array(), 'wp_template_part' );
+
+ foreach ( $templates_parts as $templates_part ) {
+ if ( ! empty( $templates_part->content ) ) {
+ $content .= $templates_part->content;
+ }
}
}
- $content .= $_wp_current_template_content;
-
$blocks = parse_blocks( $content );
if ( ! is_array( $blocks ) || empty( $blocks ) ) {
--- a/otter-blocks/inc/plugins/class-stripe-api.php
+++ b/otter-blocks/inc/plugins/class-stripe-api.php
@@ -239,7 +239,11 @@
array_push( $data, $object );
if ( defined( 'COOKIEPATH' ) && defined( 'COOKIE_DOMAIN' ) && ! headers_sent() && ! $user_id ) {
- setcookie( 'o_stripe_data', wp_json_encode( $data ), strtotime( '+1 week' ), COOKIEPATH, COOKIE_DOMAIN, false ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.cookies_setcookie
+ $data = wp_json_encode( $data );
+ $hmac_data = hash_hmac( 'sha256', $data, wp_salt() );
+ $secure = function_exists( 'is_ssl' ) ? is_ssl() : ( ! empty( $_SERVER['HTTPS'] ) && strtolower( $_SERVER['HTTPS'] ) !== 'off' ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
+ setcookie( 'o_stripe_data', $data, strtotime( '+1 week' ), COOKIEPATH, COOKIE_DOMAIN, $secure, true ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.cookies_setcookie
+ setcookie( 'o_stripe_hmac_data', $hmac_data, strtotime( '+1 week' ), COOKIEPATH, COOKIE_DOMAIN, $secure, true ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.cookies_setcookie
return;
}
@@ -258,8 +262,13 @@
$user_id = get_current_user_id();
if ( ! $user_id ) {
- if ( isset( $_COOKIE['o_stripe_data'] ) && ! empty( $_COOKIE['o_stripe_data'] ) ) { // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___COOKIE
- $data = json_decode( stripcslashes( $_COOKIE['o_stripe_data'] ), true ); // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___COOKIE, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
+ if ( isset( $_COOKIE['o_stripe_data'] ) && ! empty( $_COOKIE['o_stripe_data'] ) && isset( $_COOKIE['o_stripe_hmac_data'] ) && ! empty( $_COOKIE['o_stripe_hmac_data'] ) ) { // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___COOKIE
+ $data_raw = stripcslashes( $_COOKIE['o_stripe_data'] ); // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___COOKIE, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
+ $hmac_data = sanitize_text_field( $_COOKIE['o_stripe_hmac_data'] ); // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___COOKIE
+
+ if ( hash_equals( hash_hmac( 'sha256', $data_raw, wp_salt() ), $hmac_data ) ) {
+ $data = json_decode( $data_raw, true );
+ }
}
return $data;
--- a/otter-blocks/otter-blocks.php
+++ b/otter-blocks/otter-blocks.php
@@ -7,7 +7,7 @@
* Plugin Name: Otter – Page Builder Blocks & Extensions for Gutenberg
* Plugin URI: https://themeisle.com/plugins/otter-blocks
* Description: Create beautiful and attracting posts, pages, and landing pages with Otter – Page Builder Blocks & Extensions for Gutenberg. Otter comes with dozens of Gutenberg blocks that are all you need to build beautiful pages.
- * Version: 3.1.4
+ * Version: 3.1.5
* Author: ThemeIsle
* Author URI: https://themeisle.com
* License: GPL-2.0+
@@ -26,7 +26,7 @@
define( 'OTTER_BLOCKS_BASEFILE', __FILE__ );
define( 'OTTER_BLOCKS_URL', plugins_url( '/', __FILE__ ) );
define( 'OTTER_BLOCKS_PATH', __DIR__ );
-define( 'OTTER_BLOCKS_VERSION', '3.1.4' );
+define( 'OTTER_BLOCKS_VERSION', '3.1.5' );
define( 'OTTER_BLOCKS_PRO_SUPPORT', true );
define( 'OTTER_BLOCKS_SHOW_NOTICES', false );
define( 'OTTER_PRODUCT_SLUG', basename( OTTER_BLOCKS_PATH ) );
--- a/otter-blocks/vendor/composer/installed.php
+++ b/otter-blocks/vendor/composer/installed.php
@@ -1,8 +1,8 @@
<?php return array(
'root' => array(
'name' => 'codeinwp/otter-blocks',
- 'pretty_version' => '3.1.4',
- 'version' => '3.1.4.0',
+ 'pretty_version' => '3.1.5',
+ 'version' => '3.1.5.0',
'reference' => null,
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
@@ -11,8 +11,8 @@
),
'versions' => array(
'codeinwp/otter-blocks' => array(
- 'pretty_version' => '3.1.4',
- 'version' => '3.1.4.0',
+ 'pretty_version' => '3.1.5',
+ 'version' => '3.1.5.0',
'reference' => null,
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',