Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/lastudio-element-kit/includes/addons/advanced-carousel.php
+++ b/lastudio-element-kit/includes/addons/advanced-carousel.php
@@ -1908,10 +1908,12 @@
$item_enable_ajax = !empty($this->_processed_item['item_enable_ajax']) && filter_var($this->_processed_item['item_enable_ajax'], FILTER_VALIDATE_BOOLEAN);
+ $content = '';
+
if($item_enable_ajax && !Plugin::instance()->editor->is_edit_mode()){
$content = '<div data-lakit_ajax_loadtemplate="true" data-template-id="'.esc_attr($template_id).'"><span class="lakit-css-loader"></span></div>';
}
- else{
+ elseif ( LaStudio_Kit_Helper::can_render_template( $template_id ) ) {
ob_start();
if(Plugin::instance()->editor->is_edit_mode()){
$css_file = Post_CSS::create( $template_id );
--- a/lastudio-element-kit/includes/addons/countdown-timer.php
+++ b/lastudio-element-kit/includes/addons/countdown-timer.php
@@ -742,7 +742,7 @@
'<div class="lakit-countdown-timer__separator">%s</div>'
);
- return sprintf( $format, $separator );
+ return sprintf( $format, $this->kses_text( $separator ) );
}
protected function render() {
--- a/lastudio-element-kit/includes/addons/google-maps.php
+++ b/lastudio-element-kit/includes/addons/google-maps.php
@@ -436,6 +436,11 @@
*/
public function _get_map_style( $style ) {
+ // Only styles offered by the control are allowed (SELECT values are not validated server side).
+ if ( ! is_string( $style ) || '' === $style || false !== strpos( $style, '://' ) || false !== strpos( $style, '..' ) || ! array_key_exists( $style, $this->_get_available_map_styles() ) ) {
+ return [];
+ }
+
$full_path = untrailingslashit( ABSPATH ) . $style;
$include_path = null;
@@ -607,7 +612,7 @@
}
- $this->add_render_attribute( 'map-data', 'data-pins', wp_json_encode( $pins ) );
+ $this->add_render_attribute( 'map-data', 'data-pins', wp_json_encode( $pins, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT ) );
$this->add_render_attribute( 'map-data', 'class', 'lakit-gmap' );
echo sprintf( '<div %s></div>', $this->get_render_attribute_string( 'map-data' ) );
--- a/lastudio-element-kit/includes/addons/hamburger-panel.php
+++ b/lastudio-element-kit/includes/addons/hamburger-panel.php
@@ -742,7 +742,7 @@
$toggle_label_html = '';
if ( ! empty( $panel_settings['panel_toggle_label'] ) ) {
- $toggle_label_html .= sprintf( '<div class="lakit-hamburger-panel__toggle-label"><span>%1$s</span></div>', $panel_settings['panel_toggle_label'] );
+ $toggle_label_html .= sprintf( '<div class="lakit-hamburger-panel__toggle-label"><span>%1$s</span></div>', $this->kses_text( $panel_settings['panel_toggle_label'] ) );
}
$toggle_html = sprintf( '<div class="lakit-hamburger-panel__toggle main-color">%1$s%2$s</div>', $toggle_control_html, $toggle_label_html );
@@ -779,7 +779,7 @@
if($template_id == get_queried_object_id()){
$content_html .= '<span class="lakit-css-loader"></span>';
}
- else if ( ! empty( $template_id ) && ( !$ajax_template || Plugin::instance()->editor->is_edit_mode() ) ) {
+ else if ( ! empty( $template_id ) && LaStudio_Kit_Helper::can_render_template( $template_id ) && ( !$ajax_template || Plugin::instance()->editor->is_edit_mode() ) ) {
ob_start();
if(Plugin::instance()->editor->is_edit_mode()){
$css_file = Post_CSS::create( $template_id );
--- a/lastudio-element-kit/includes/addons/hotspots.php
+++ b/lastudio-element-kit/includes/addons/hotspots.php
@@ -725,7 +725,7 @@
],
] );
- $this->update_control(
+ $this->update_responsive_control(
'width',
[
'selectors' => [
@@ -734,7 +734,7 @@
]
);
- $this->update_control(
+ $this->update_responsive_control(
'space',
[
'selectors' => [
@@ -743,7 +743,7 @@
]
);
- $this->update_control(
+ $this->update_responsive_control(
'height',
[
'selectors' => [
@@ -1515,7 +1515,7 @@
<?php if ( $hotspot['hotspot_label'] ) : ?>
<div class="lakit-hotspot__label"><?php
// PHPCS - the main text of a widget should not be escaped.
- echo $hotspot['hotspot_label']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ echo wp_kses_post( $hotspot['hotspot_label'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
?></div>
<?php endif; ?>
<?php endif; ?>
--- a/lastudio-element-kit/includes/addons/image-compare.php
+++ b/lastudio-element-kit/includes/addons/image-compare.php
@@ -586,7 +586,7 @@
'after' => $after_title,
],
'controlType' => $this->get_settings_for_display('control_type')
- ]);
+ ], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT);
}
}
--- a/lastudio-element-kit/includes/addons/instagram-feed.php
+++ b/lastudio-element-kit/includes/addons/instagram-feed.php
@@ -1206,7 +1206,7 @@
$item_html = sprintf( $link_format, esc_url( $link ), $item_html, $attr );
}
- $html .= sprintf( '<div class="lakit-instagram-feed__item %s"><div class="lakit-instagram-feed__inner">%s</div></div>', $col_class, $item_html );
+ $html .= sprintf( '<div class="lakit-instagram-feed__item %s"><div class="lakit-instagram-feed__inner">%s</div></div>', esc_attr( $col_class ), $item_html );
}
} else {
@@ -1334,7 +1334,7 @@
if ( $this->config['post_comments_count'] ) {
$meta_html .= sprintf(
'<div class="lakit-instagram-feed__meta-item lakit-instagram-feed__comments-count"><span class="lakit-instagram-feed__comments-icon lakit-instagram-feed__meta-icon"><i class="%s"></i></span><span class="lakit-instagram-feed__comments-label lakit-instagram-feed__meta-label">%s</span></div>',
- $this->get_settings_for_display( 'comments_icon' ),
+ esc_attr( $this->get_settings_for_display( 'comments_icon' ) ),
$item['comments']
);
}
@@ -1342,7 +1342,7 @@
if ( $this->config['post_likes_count'] ) {
$meta_html .= sprintf(
'<div class="lakit-instagram-feed__meta-item lakit-instagram-feed__likes-count"><span class="lakit-instagram-feed__likes-icon lakit-instagram-feed__meta-icon"><i class="%s"></i></span><span class="lakit-instagram-feed__likes-label lakit-instagram-feed__meta-label">%s</span></div>',
- $this->get_settings_for_display( 'likes_icon' ),
+ esc_attr( $this->get_settings_for_display( 'likes_icon' ) ),
$item['likes']
);
}
--- a/lastudio-element-kit/includes/addons/login.php
+++ b/lastudio-element-kit/includes/addons/login.php
@@ -818,10 +818,10 @@
$password_placeholder = $settings['label_password'];
}
- $login_form = str_replace(['id="user_login"', 'id="user_pass"'], ['id="user_login" placeholder="'.$username_placeholder.'"', 'id="user_pass" placeholder="'.$password_placeholder.'"'], $login_form);
+ $login_form = str_replace(['id="user_login"', 'id="user_pass"'], ['id="user_login" placeholder="'.esc_attr($username_placeholder).'"', 'id="user_pass" placeholder="'.esc_attr($password_placeholder).'"'], $login_form);
if(filter_var($this->get_settings_for_display('lost_password_link'), FILTER_VALIDATE_BOOLEAN)){
- $lost_password_link = sprintf('<a class="lakit-login-lost-password-link" href="%1$s">%2$s</a>', esc_url(wp_lostpassword_url()), $this->get_settings_for_display('lost_password_link_text'));
+ $lost_password_link = sprintf('<a class="lakit-login-lost-password-link" href="%1$s">%2$s</a>', esc_url(wp_lostpassword_url()), $this->kses_text( $this->get_settings_for_display('lost_password_link_text') ));
$login_form = str_replace('<p class="login-remember">', '<p class="login-remember">' . $lost_password_link, $login_form);
}
--- a/lastudio-element-kit/includes/addons/nav-menu.php
+++ b/lastudio-element-kit/includes/addons/nav-menu.php
@@ -2429,8 +2429,7 @@
),
),
'selectors' => array(
- '{{WRAPPER}} .lakit-active--mbmenu .lakit-nav.lakit-nav-{{ID}}' => 'width: {{SIZE}}{{UNIT}};',
- '{{WRAPPER}} .lakit-mobile-menu--full-width .lakit-nav-{{ID}}' => 'min-width: {{SIZE}}{{UNIT}};',
+ '{{WRAPPER}}' => '--enav_menumobile_width: {{SIZE}}{{UNIT}};'
),
'condition' => array(
'mobile_menu_layout!' => 'default'
@@ -3205,7 +3204,7 @@
$this->add_render_attribute( 'nav-wrapper', 'class', 'lakit-nav-layout--' . esc_attr( $layout) );
$this->add_render_attribute( 'nav-wrapper', 'data-effect', $menu_effect );
$this->add_render_attribute( 'nav-wrapper', 'data-dlconfig', wp_json_encode([
- 'backtext' => sprintf('<span>%1$s</span>', $dlmenu_back_text),
+ 'backtext' => sprintf('<span>%1$s</span>', esc_html( wp_strip_all_tags( wp_specialchars_decode( (string) $dlmenu_back_text, ENT_QUOTES ) ) )),
'backicon' => $dlmenu_back_icon,
'triggericon' => $dlmenu_trigger_icon,
]));
@@ -3242,7 +3241,7 @@
$mobile_extra_block_html = '<div class="lakit-nav-custom-block-after" data-template-id="'.esc_attr($mobile_after_template_id).'"><span class="lakit-css-loader"></span></div>';
}
else{
- if(Plugin::instance()->editor->is_edit_mode()){
+ if(Plugin::instance()->editor->is_edit_mode() && LaStudio_Kit_Helper::can_render_template( $mobile_after_template_id )){
ob_start();
$css_file = Post_CSS::create( $mobile_after_template_id );
echo sprintf('<link rel="stylesheet" id="elementor-post-%1$s-css" href="%2$s" type="text/css" media="all" />', esc_attr($mobile_after_template_id), esc_url($css_file->get_url()) );
@@ -3300,7 +3299,7 @@
echo $this->_get_icon('toggle_icon', '<span class="nav-toggle-icon">%s</span>'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $this->_get_html('toggle_text', '<span class="nav-toggle-text">%s</span>'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
if(!empty($dropdown_icon)){
- echo sprintf('<span class="nav-toggle-icondrop"><i class="%1$s"></i></span>', $dropdown_icon); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ echo sprintf('<span class="nav-toggle-icondrop"><i class="%1$s"></i></span>', esc_attr( $dropdown_icon )); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
?></button>
<?php
--- a/lastudio-element-kit/includes/addons/post-author.php
+++ b/lastudio-element-kit/includes/addons/post-author.php
@@ -350,11 +350,24 @@
$animation_class = ! empty( $settings['hover_animation'] ) ? 'elementor-animation-' . $settings['hover_animation'] : '';
+ // `image` is HTML by design (the <img> from get_avatar()) and the bio may legitimately
+ // carry formatting, so it goes through kses. Every other field is a raw profile value
+ // and is escaped before it reaches the markup.
+ if ( 'image' === $settings['author'] ) {
+ $author_html = $author;
+ }
+ elseif ( 'description' === $settings['author'] ) {
+ $author_html = wp_kses_post( $author );
+ }
+ else {
+ $author_html = esc_html( $author );
+ }
+
$html = sprintf( '<%1$s class="lakit-post-author %2$s">', $html_tag, esc_attr($animation_class) );
if ( $link ) {
- $html .= sprintf( '<a href="%1$s" %2$s>%3$s</a>', $link, $target, $author );
+ $html .= sprintf( '<a href="%1$s" %2$s>%3$s</a>', $link, $target, $author_html );
} else {
- $html .= $author;
+ $html .= $author_html;
}
$html .= sprintf( '</%s>', $html_tag );
@@ -364,12 +377,7 @@
protected function content_template() {
?>
<#
- var author_data = [];
- <?php
- foreach ( $this->user_data() as $key => $value ) {
- printf( 'author_data[ "%1$s" ] = "%2$s";', $key, $value ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- }
- ?>
+ var author_data = <?php echo wp_json_encode( (object) $this->user_data(), JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>;
var author = author_data[ settings.author ];
var htmlTag = elementor.helpers.validateHTMLTag(settings.html_tag);
@@ -398,11 +406,19 @@
animation_class = 'elementor-animation-' + settings.hover_animation;
}
+ if ( link_url && /^s*(javascript|data|vbscript):/i.test( link_url ) ) {
+ link_url = false;
+ }
+
+ // `image` is HTML by design (the <img> from get_avatar()); every other field is a raw
+ // profile value, so it is escaped before it goes into the markup.
+ var author_html = ( 'image' === settings.author ) ? author : _.escape( author || '' );
+
var html = '<' + htmlTag + ' class="lakit-post-author ' + animation_class + '">';
if ( link_url ) {
- html += '<a href="' + link_url + '" ' + target + '>' + author + '</a>';
+ html += '<a href="' + _.escape( link_url ) + '" ' + target + '>' + author_html + '</a>';
} else {
- html += author;
+ html += author_html;
}
html += '</' + htmlTag + '>';
--- a/lastudio-element-kit/includes/addons/post-featured-image.php
+++ b/lastudio-element-kit/includes/addons/post-featured-image.php
@@ -402,7 +402,7 @@
$target = $settings['link']['is_external'] ? 'target="_blank"' : '';
$a_atts[] = $target;
- $animation_class = ! empty( $settings['hover_animation'] ) ? 'elementor-animation-' . $settings['hover_animation'] : '';
+ $animation_class = ! empty( $settings['hover_animation'] ) ? 'elementor-animation-' . sanitize_html_class( $settings['hover_animation'] ) : '';
$html = '<div class="lakit-post-featured-image ' . $animation_class . '">';
if ( $link ) {
--- a/lastudio-element-kit/includes/addons/post-info.php
+++ b/lastudio-element-kit/includes/addons/post-info.php
@@ -403,7 +403,7 @@
break;
case 'custom_field':
if( !empty($meta['item_ckey']) ){
- $meta_value = get_post_meta( get_the_ID(), $meta['item_ckey'], true );
+ $meta_value = LaStudio_Kit_Helper::get_public_post_meta( get_the_ID(), $meta['item_ckey'] );
}
$item_type_class = 'cf__' . $item_type;
break;
@@ -418,7 +418,7 @@
}
if (!empty($meta_value)) {
- $output .= sprintf('<div class="lakit-posts__meta__item lakit-posts__meta__item--%4$s %5$s">%1$s%2$s%3$s</div>', $meta_icon, $meta_label, $meta_value, $item_type, $item_type_class);
+ $output .= sprintf('<div class="lakit-posts__meta__item lakit-posts__meta__item--%4$s %5$s">%1$s%2$s%3$s</div>', $meta_icon, $meta_label, $meta_value, esc_attr( $item_type ), esc_attr( $item_type_class ));
}
}
--- a/lastudio-element-kit/includes/addons/post-meta.php
+++ b/lastudio-element-kit/includes/addons/post-meta.php
@@ -396,7 +396,7 @@
case 'custom_field':
if( !empty($meta['item_ckey']) ){
$ckey = $meta['item_ckey'];
- $meta_value = get_post_meta( $post->ID, $meta['item_ckey'], true );
+ $meta_value = LaStudio_Kit_Helper::get_public_post_meta( $post->ID, $meta['item_ckey'] );
if( $post_type === 'la_event' && in_array($ckey, ['event_start_date', 'event_end_date'])){
if( lastudio_kit_helper()->validate_date($meta_value, 'Y-m-d') ){
$meta_value = date(get_option( 'date_format', 'M j, Y'), strtotime($meta_value));
@@ -428,7 +428,7 @@
}
if (!empty($meta_value)) {
- $output .= sprintf('<div class="lakit-pf-meta__item lakit-pf-meta__item--%4$s %5$s">%1$s%2$s%3$s</div>', $meta_icon, $meta_label, $meta_value, $item_type, $item_type_class);
+ $output .= sprintf('<div class="lakit-pf-meta__item lakit-pf-meta__item--%4$s %5$s">%1$s%2$s%3$s</div>', $meta_icon, $meta_label, $meta_value, esc_attr( $item_type ), esc_attr( $item_type_class ));
}
}
--- a/lastudio-element-kit/includes/addons/slides.php
+++ b/lastudio-element-kit/includes/addons/slides.php
@@ -1615,8 +1615,14 @@
echo '<div class="lakit-carousel__dots lakit-carousel__dots_'.esc_attr($this->get_id()).' swiper-pagination"></div>';
}
if ( filter_var( $this->get_settings_for_display( 'carousel_arrows' ), FILTER_VALIDATE_BOOLEAN ) ) {
- echo sprintf( '<div class="lakit-carousel__prev-arrow-%s lakit-arrow prev-arrow">%s</div>', esc_attr($this->get_id()), $this->_render_icon( 'carousel_prev_arrow', '%s', '', false ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- echo sprintf( '<div class="lakit-carousel__next-arrow-%s lakit-arrow next-arrow">%s</div>', esc_attr($this->get_id()), $this->_render_icon( 'carousel_next_arrow', '%s', '', false ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ echo sprintf(
+ '<div class="lakit-carousel__prev-arrow-%s lakit-arrow prev-arrow">%s</div>',
+ esc_attr($this->get_id()),
+ $this->_render_icon( is_rtl() ? 'carousel_next_arrow' : 'carousel_prev_arrow', '%s', '', false ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ echo sprintf(
+ '<div class="lakit-carousel__next-arrow-%s lakit-arrow next-arrow">%s</div>',
+ esc_attr($this->get_id()),
+ $this->_render_icon( is_rtl() ? 'carousel_next_arrow' : 'carousel_prev_arrow', '%s', '', false ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
if ( filter_var( $this->get_settings_for_display( 'carousel_scrollbar' ), FILTER_VALIDATE_BOOLEAN ) ) {
echo sprintf('<div class="lakit-carousel__scrollbar swiper-scrollbar lakit-carousel__scrollbar_%1$s"></div>', esc_attr($this->get_id()));
--- a/lastudio-element-kit/includes/addons/table-of-contents.php
+++ b/lastudio-element-kit/includes/addons/table-of-contents.php
@@ -693,7 +693,7 @@
$html_tag = Utils::validate_html_tag( $settings['html_tag'] );
?>
<div class="lakit-toc__header">
- <?php echo '<' . $html_tag . ' class="lakit-toc__header-title">' . $settings['title'] . '</' . $html_tag . '>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
+ <?php echo '<' . $html_tag . ' class="lakit-toc__header-title">' . $this->kses_text( $settings['title'] ) . '</' . $html_tag . '>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php if ( 'yes' === $settings['minimize_box'] ) : ?>
<div class="lakit-toc__toggle-button lakit-toc__toggle-button--expand"><?php Icons_Manager::render_icon( $settings['expand_icon'] ); ?></div>
<div class="lakit-toc__toggle-button lakit-toc__toggle-button--collapse"><?php Icons_Manager::render_icon( $settings['collapse_icon'] ); ?></div>
--- a/lastudio-element-kit/includes/addons/tabs.php
+++ b/lastudio-element-kit/includes/addons/tabs.php
@@ -1722,10 +1722,10 @@
$title_label_html = '';
if ( ! empty( $item['item_sublabel'] ) ) {
- $title_label_html .= sprintf( '<div class="lakit-tabs__sublabel-text">%1$s</div>', $item['item_sublabel'] );
+ $title_label_html .= sprintf( '<div class="lakit-tabs__sublabel-text">%1$s</div>', $this->kses_text( $item['item_sublabel'] ) );
}
if ( ! empty( $item['item_label'] ) ) {
- $title_label_html .= sprintf( '<div class="lakit-tabs__label-text">%1$s</div>', $item['item_label'] );
+ $title_label_html .= sprintf( '<div class="lakit-tabs__label-text">%1$s</div>', $this->kses_text( $item['item_label'] ) );
}
if ( ! empty( $title_label_html ) ) {
$title_label_html = sprintf( '<div class="lakit-tabs__label">%1$s</div>', wp_kses($title_label_html, LaStudio_Kit_Helper::kses_allowed_tags()) );
@@ -1801,8 +1801,11 @@
$template_content = '<div data-lakit_ajax_loadtemplate="true" data-template-id="' . esc_attr( $item['item_template_id'] ) . '"><span class="lakit-css-loader"></span></div>';
} else {
+ if ( ! LaStudio_Kit_Helper::can_render_template( $item['item_template_id'] ) ) {
+ $item['item_template_id'] = 0;
+ }
ob_start();
- if(Plugin::instance()->editor->is_edit_mode()){
+ if(!empty($item['item_template_id']) && Plugin::instance()->editor->is_edit_mode()){
$css_file = Post_CSS::create( $item['item_template_id'] );
echo sprintf('<link rel="stylesheet" id="elementor-post-%1$s-css" href="%2$s" type="text/css" media="all" />', esc_attr($item['item_template_id']), esc_url($css_file->get_url()) );
}
--- a/lastudio-element-kit/includes/addons/team-member.php
+++ b/lastudio-element-kit/includes/addons/team-member.php
@@ -1985,7 +1985,7 @@
$icon_key = 's_icon_' . $i;
$link_key = 's_link_' . $i;
$att_uid = 'member_'.$uid . '_social_' . $i;
- if(!empty($member_item[$icon_key])){
+ if(!empty($member_item[$icon_key]) && is_string($member_item[$icon_key]) && isset($icon_lists[$member_item[$icon_key]])){
$icon_value = $member_item[$icon_key];
$icon_name = $icon_lists[$icon_value];
if ( !empty($member_item[$link_key]) && ! empty( $member_item[$link_key]['url'] ) ) {
@@ -1993,7 +1993,7 @@
$this->add_render_attribute( $att_uid, 'title', esc_attr($icon_name) );
}
$this->add_render_attribute( $att_uid, 'class', sprintf('social-%1$s %1$s', strtolower($icon_name)) );
- $html .= sprintf('<a %1$s><i class="%2$s"></i></a>', $this->get_render_attribute_string( $att_uid ), $icon_value);
+ $html .= sprintf('<a %1$s><i class="%2$s"></i></a>', $this->get_render_attribute_string( $att_uid ), esc_attr( $icon_value ));
}
}
if(!empty($html)){
--- a/lastudio-element-kit/includes/addons/template.php
+++ b/lastudio-element-kit/includes/addons/template.php
@@ -70,7 +70,7 @@
$template_id = apply_filters('wpml_object_id', $template_id, 'elementor_library', true);
- $is_valid = !empty($template_id) && 'publish' === get_post_status( $template_id );
+ $is_valid = !empty($template_id) && 'publish' === get_post_status( $template_id ) && LaStudio_Kit_Helper::can_render_template( $template_id );
if ( $is_valid ) {
ob_start();
--- a/lastudio-element-kit/includes/addons/twitter.php
+++ b/lastudio-element-kit/includes/addons/twitter.php
@@ -577,8 +577,8 @@
echo '<div class="lakit-carousel__dots lakit-carousel__dots_' . esc_attr($this->get_id()) . ' swiper-pagination"></div>';
}
if ( filter_var( $this->get_settings_for_display( 'carousel_arrows' ), FILTER_VALIDATE_BOOLEAN ) ) {
- echo sprintf( '<div class="lakit-carousel__prev-arrow-%s lakit-arrow prev-arrow">%s</div>', esc_attr($this->get_id()), $this->_render_icon( 'carousel_prev_arrow', '%s', '', false ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- echo sprintf( '<div class="lakit-carousel__next-arrow-%s lakit-arrow next-arrow">%s</div>', esc_attr($this->get_id()), $this->_render_icon( 'carousel_next_arrow', '%s', '', false ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ echo sprintf( '<div class="lakit-carousel__prev-arrow-%s lakit-arrow prev-arrow">%s</div>', esc_attr($this->get_id()), $this->_render_icon( is_rtl() ? 'carousel_next_arrow' : 'carousel_prev_arrow', '%s', '', false ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ echo sprintf( '<div class="lakit-carousel__next-arrow-%s lakit-arrow next-arrow">%s</div>', esc_attr($this->get_id()), $this->_render_icon( is_rtl() ? 'carousel_prev_arrow' : 'carousel_next_arrow', '%s', '', false ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
if ( filter_var( $this->get_settings_for_display( 'carousel_scrollbar' ), FILTER_VALIDATE_BOOLEAN ) ) {
echo sprintf('<div class="lakit-carousel__scrollbar swiper-scrollbar lakit-carousel__scrollbar_%1$s"></div>', esc_attr($this->get_id()));
--- a/lastudio-element-kit/includes/addons/vendor/woo-filters.php
+++ b/lastudio-element-kit/includes/addons/vendor/woo-filters.php
@@ -1659,7 +1659,7 @@
$filters = $this->get_settings_for_display('filters');
$this->_processed_item = false;
if(!empty($filters)){
- echo sprintf('<div class="lakit-woofilters lakit-woofilters--layout_%1$s lakit-woofilters--type_%2$s %3$s">', $layout, $type, $item_as_dropdown);
+ echo sprintf('<div class="lakit-woofilters lakit-woofilters--layout_%1$s lakit-woofilters--type_%2$s %3$s">', esc_attr( $layout ), esc_attr( $type ), esc_attr( $item_as_dropdown ));
if($layout != 'default'){
echo sprintf('<div class="lakit-woofilters_block_label"><span class="woofilter-litem">%1$s%2$s</span></div>', $filters_label, $filters_icon);
}
--- a/lastudio-element-kit/includes/addons/vendor/woo-products.php
+++ b/lastudio-element-kit/includes/addons/vendor/woo-products.php
@@ -6182,8 +6182,8 @@
$carousel_dot_html = '<div class="lakit-carousel__dots lakit-carousel__dots_'.$unique_id.' swiper-pagination"></div>';
}
if (filter_var($this->get_settings_for_display('carousel_arrows'), FILTER_VALIDATE_BOOLEAN)) {
- $carousel_arrow_html = sprintf('<div class="lakit-carousel__prev-arrow-%s lakit-arrow prev-arrow">%s</div>', $unique_id, $this->_render_icon('carousel_prev_arrow', '%s', '', false));
- $carousel_arrow_html .= sprintf('<div class="lakit-carousel__next-arrow-%s lakit-arrow next-arrow">%s</div>', $unique_id, $this->_render_icon('carousel_next_arrow', '%s', '', false));
+ $carousel_arrow_html = sprintf('<div class="lakit-carousel__prev-arrow-%s lakit-arrow prev-arrow">%s</div>', $unique_id, $this->_render_icon(is_rtl() ? 'carousel_next_arrow' : 'carousel_prev_arrow', '%s', '', false));
+ $carousel_arrow_html .= sprintf('<div class="lakit-carousel__next-arrow-%s lakit-arrow next-arrow">%s</div>', $unique_id, $this->_render_icon(is_rtl() ? 'carousel_prev_arrow' :'carousel_next_arrow', '%s', '', false));
}
if (filter_var($this->get_settings_for_display('carousel_scrollbar'), FILTER_VALIDATE_BOOLEAN)) {
$carousel_scrollbar_html = sprintf('<div class="lakit-carousel__scrollbar swiper-scrollbar lakit-carousel__scrollbar_%1$s"></div>', $unique_id);
--- a/lastudio-element-kit/includes/base/class-widget-base.php
+++ b/lastudio-element-kit/includes/base/class-widget-base.php
@@ -376,7 +376,7 @@
}
if (!empty($value)) {
- return sprintf($format, $value);
+ return sprintf($format, self::kses_text($value));
}
return false;
}
@@ -509,6 +509,32 @@
* @param [type] $format [description]
* @return [type] [description]
*/
+ /**
+ * Allowed HTML for text settings printed by the widget templates.
+ *
+ * @return array
+ */
+ public static function get_allowed_text_html() {
+ static $allowed = null;
+ if ( null === $allowed ) {
+ $allowed = array_merge( wp_kses_allowed_html( 'post' ), LaStudio_Kit_Helper::kses_allowed_tags() );
+ }
+ return $allowed;
+ }
+
+ /**
+ * Strip unsafe HTML (scripts, event handlers...) from a text value.
+ *
+ * @param mixed $value
+ * @return mixed
+ */
+ public static function kses_text( $value ) {
+ if ( ! is_string( $value ) ) {
+ return $value;
+ }
+ return wp_kses( $value, self::get_allowed_text_html() );
+ }
+
public function _render_html($setting = null, $format = '%s')
{
@@ -532,10 +558,10 @@
}
if (is_array($val)) {
- printf($format, $val[$key]); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ printf($format, self::kses_text($val[$key])); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- sanitized with wp_kses.
}
else {
- printf($format, $val); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ printf($format, self::kses_text($val)); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- sanitized with wp_kses.
}
}
@@ -685,7 +711,7 @@
$icon_class .= ' ' . $settings[$setting];
}
- $icon_html = sprintf('<i class="%s" aria-hidden="true"></i>', $icon_class);
+ $icon_html = sprintf('<i class="%s" aria-hidden="true"></i>', esc_attr( $icon_class ));
}
if (empty($icon_html)) {
--- a/lastudio-element-kit/includes/class-helper.php
+++ b/lastudio-element-kit/includes/class-helper.php
@@ -715,11 +715,11 @@
arsort($breakpoints);
$css = [];
- $css[] = sprintf('%1$s{--e-c-col:%2$s}', $css_selector, $columns['desktop'] ?? 1);
+ $css[] = sprintf('%1$s{--e-c-col:%2$s}', $css_selector, (float) ( $columns['desktop'] ?? 1 ));
foreach ($breakpoints as $k => $vl){
if( isset($columns[$k]) ){
- $css[] = sprintf('@media(max-width: %3$spx){%1$s{--e-c-col:%2$s}}', $css_selector, $columns[$k], $vl);
+ $css[] = sprintf('@media(max-width: %3$spx){%1$s{--e-c-col:%2$s}}', $css_selector, (float) $columns[$k], absint( $vl ));
}
}
return join('', $css);
@@ -1231,6 +1231,33 @@
}
+ /**
+ * Whether the current visitor may see the rendered Elementor content of a post/template
+ * referenced by ID from a widget setting (settings are not validated server side).
+ */
+ public static function can_render_template( $template_id ){
+ $post = get_post( absint( $template_id ) );
+ if ( ! $post || post_password_required( $post ) ) {
+ return false;
+ }
+ if ( 'publish' === $post->post_status ) {
+ return true;
+ }
+ return current_user_can( 'read_post', $post->ID );
+ }
+
+ /**
+ * Read a custom field chosen in a widget setting: protected (`_` prefixed) keys are refused
+ * and the value is limited to safe HTML.
+ */
+ public static function get_public_post_meta( $post_id, $meta_key ){
+ if ( ! is_string( $meta_key ) || '' === $meta_key || is_protected_meta( $meta_key, 'post' ) ) {
+ return '';
+ }
+ $value = get_post_meta( $post_id, $meta_key, true );
+ return is_scalar( $value ) ? wp_kses_post( (string) $value ) : '';
+ }
+
public static function string_to_bool( $string ){
$string = $string ?? '';
return is_bool( $string ) ? $string : ( 'yes' === strtolower( $string ) || 1 === $string || 'true' === strtolower( $string ) || '1' === $string );
--- a/lastudio-element-kit/includes/class-integration.php
+++ b/lastudio-element-kit/includes/class-integration.php
@@ -88,8 +88,6 @@
add_filter('elementor/widgets/black_list', [ $this, 'e_widget_blacklist' ], 20);
add_filter('elementor/editor/localize_settings', [ $this, 'e_pro_widgets' ], 20);
- add_filter('elementor/shapes/additional_shapes', [ $this, 'e_shapes' ], 20);
-
add_action( 'elementor/frontend/before_enqueue_scripts', [ $this, 'enqueue_frontend_scripts' ] );
add_filter( 'woocommerce_add_to_cart_redirect', [ $this, 'woocommerce_add_to_cart_redirect' ], 100, 1 );
@@ -120,6 +118,7 @@
'subscribe_success' => esc_html__( 'Success', 'lastudio-kit' ),
'invalid_captcha' => esc_html__( 'reCAPTCHA response token is invalid.', 'lastudio-kit' ),
'require_field' => esc_html__( 'Please fill out this field.', 'lastudio-kit' ),
+ 'rate_limited' => esc_html__( 'Too many requests. Please wait a moment.', 'lastudio-kit' ),
) );
}
@@ -702,11 +701,11 @@
throw new Exception( $signon->get_error_message() );
}
- $redirect = isset( $_POST['redirect_to'] )
- ? esc_url( $_POST['redirect_to'] )
- : esc_url( home_url( '/' ) );
+ $redirect = isset( $_POST['redirect_to'] ) && is_string( $_POST['redirect_to'] )
+ ? wp_validate_redirect( wp_unslash( $_POST['redirect_to'] ), home_url( '/' ) )
+ : home_url( '/' );
- wp_redirect( $redirect );
+ wp_safe_redirect( $redirect );
exit;
} catch ( Exception $e ) {
@@ -753,13 +752,13 @@
$current_user = get_user_by( 'id', $user );
wp_set_auth_cookie( $user, true );
- if ( ! empty( $_POST['lakit_redirect'] ) ) {
- $redirect = wp_sanitize_redirect( $_POST['lakit_redirect'] );
+ if ( ! empty( $_POST['lakit_redirect'] ) && is_string( $_POST['lakit_redirect'] ) ) {
+ $redirect = wp_unslash( $_POST['lakit_redirect'] );
} else {
- $redirect = $_POST['_wp_http_referer'];
+ $redirect = isset( $_POST['_wp_http_referer'] ) && is_string( $_POST['_wp_http_referer'] ) ? wp_unslash( $_POST['_wp_http_referer'] ) : '';
}
- wp_redirect( $redirect );
+ wp_safe_redirect( wp_validate_redirect( $redirect, home_url( '/' ) ) );
exit;
} catch ( Exception $e ) {
@@ -778,7 +777,7 @@
*/
public function create_user( $username, $email, $password ) {
- if('yes' !== get_option( 'woocommerce_enable_myaccount_registration' ) && 'yes' !== get_option( 'users_can_register' )){
+ if(! ( function_exists( 'WC' ) && 'yes' === get_option( 'woocommerce_enable_myaccount_registration' ) ) && ! get_option( 'users_can_register' )){
return new WP_Error(
'registration-error-disable',
__( 'This feature is not available.', 'lastudio-kit' )
@@ -1044,7 +1043,11 @@
$api_server = sprintf( 'https://%s.api.mailchimp.com/3.0/', $key_data[1] );
- $url = esc_url( trailingslashit( $api_server . 'lists/' . $list_id . '/members/' ) );
+ if ( ! preg_match( '/^[a-zA-Z0-9]{1,32}$/', (string) $list_id ) || ! preg_match( '/^[a-z]{2,4}[0-9]{1,3}$/', $key_data[1] ) ) {
+ return false;
+ }
+
+ $url = esc_url( trailingslashit( $api_server . 'lists/' . rawurlencode( $list_id ) . '/members/' ) );
$data = wp_json_encode( $args );
@@ -1090,15 +1093,41 @@
* @param LaStudio_Kit_Ajax_Manager $ajax_manager
*/
public function register_ajax_actions( $ajax_manager ){
- $ajax_manager->register_ajax_action( 'newsletter_subscribe', [ $this, 'ajax_newsletter_subscribe' ], false );
- $ajax_manager->register_ajax_action( 'elementor_template', [ $this, 'ajax_get_elementor_template' ], false);
- $ajax_manager->register_ajax_action( 'elementor_widget', [ $this, 'ajax_get_elementor_widget' ], false);
+ /**
+ * These actions are reachable over wp_ajax_nopriv_ and used to skip the nonce
+ * check entirely, which let any anonymous visitor drive the template renderer.
+ *
+ * The nonce is printed on the front end as LaStudioKitSettings.ajaxNonce and the
+ * bundled scripts already send it as `_nonce`. If a full-page cache serves HTML
+ * older than the nonce lifetime (24h) the nonce can go stale; in that case opt
+ * back out with:
+ *
+ * add_filter( 'lastudio-kit/ajax/protected_public_actions', '__return_false' );
+ */
+ $protect_public = (bool) apply_filters( 'lastudio-kit/ajax/protected_public_actions', true );
+
+ $ajax_manager->register_ajax_action( 'newsletter_subscribe', [ $this, 'ajax_newsletter_subscribe' ], $protect_public );
+ $ajax_manager->register_ajax_action( 'elementor_template', [ $this, 'ajax_get_elementor_template' ], $protect_public );
+ $ajax_manager->register_ajax_action( 'elementor_widget', [ $this, 'ajax_get_elementor_widget' ], $protect_public );
$ajax_manager->register_ajax_action( 'login', [ $this, 'ajax_login_handle' ], true );
$ajax_manager->register_ajax_action( 'register', [ $this, 'ajax_register_handle' ], true );
}
public function ajax_newsletter_subscribe( $request ){
+ /**
+ * Every accepted call makes an outbound MailChimp API request, so this one is
+ * throttled harder than the template renderers and is counted on its own bucket.
+ */
+ $rate_limit = LaStudioKitTemplate_Helper::apply_rate_limit( 'lakit_rl_newsletter_', 10 );
+
+ if ( is_wp_error( $rate_limit ) ) {
+ return [
+ 'type' => 'error',
+ 'message' => $this->sys_messages['rate_limited'] ?? $rate_limit->get_error_message(),
+ ];
+ }
+
$api_key = apply_filters('lastudio-kit/mailchimp/api', lastudio_kit_settings()->get_option('mailchimp-api-key'));
$list_id = apply_filters('lastudio-kit/mailchimp/list_id', lastudio_kit_settings()->get_option('mailchimp-list-id'));
$double_opt = apply_filters('lastudio-kit/mailchimp/double_opt_in', lastudio_kit_settings()->get_option('mailchimp-double-opt-in'));
@@ -1117,7 +1146,14 @@
filter_var( $request['use_target_list_id'], FILTER_VALIDATE_BOOLEAN ) &&
! empty( $request['target_list_id'] )
) {
- $list_id = esc_attr($request['target_list_id']);
+ $target_list_id = is_scalar( $request['target_list_id'] ) ? (string) $request['target_list_id'] : '';
+ if ( ! preg_match( '/^[a-zA-Z0-9]{1,32}$/', $target_list_id ) ) {
+ return [
+ 'type' => 'error',
+ 'message' => $this->sys_messages['mailchimp'],
+ ];
+ }
+ $list_id = $target_list_id;
}
if ( ! $list_id ) {
@@ -1200,9 +1236,9 @@
'template_metadata' => []
];
$args = [
- 'dev' => !empty($request['dev']) ? $request['dev'] : false
+ 'dev' => !empty($request['dev']) && current_user_can( 'edit_posts' ) ? $request['dev'] : false
];
- $template_ids = !empty($request['template_ids']) ? (array) $request['template_ids'] : [];
+ $template_ids = !empty($request['template_ids']) ? array_slice( array_unique( array_filter( array_map( 'absint', (array) $request['template_ids'] ) ) ), 0, 10 ) : [];
if(empty($template_ids)){
return [ $template_data ];
}
@@ -1227,7 +1263,9 @@
}
}
}
- $is_dev = !empty($request['dev']) && LaStudio_Kit_Helper::string_to_bool($request['dev']);
+ $is_dev = !empty($request['dev']) && LaStudio_Kit_Helper::string_to_bool($request['dev']) && current_user_can( 'edit_posts' );
+ // Only `filter` is used by the renderer; drop anything else so arbitrary keys cannot create new cache entries.
+ $widget_args = is_array( $widget_args ) && isset( $widget_args['filter'] ) ? [ 'filter' => absint( $widget_args['filter'] ) ] : [];
/**
* disable cache if is wc filters
*/
@@ -1236,7 +1274,7 @@
}
$args = [
'template_id' => !empty($request['template_id']) ? absint($request['template_id']) : false,
- 'widget_id' => !empty($request['widget_id']) ? $request['widget_id'] : false,
+ 'widget_id' => !empty($request['widget_id']) && is_scalar($request['widget_id']) ? sanitize_key( $request['widget_id'] ) : false,
'widget_args' => !empty($widget_args) ? $widget_args : false,
'dev' => $is_dev
];
@@ -1446,7 +1484,7 @@
return [
'type' => 'success',
'message' => __('Logged in successful', 'lastudio-kit'),
- 'redirect_to' => esc_url($request['redirect_to'] ?? $request['redirect'] ?? home_url('/') )
+ 'redirect_to' => esc_url( wp_validate_redirect( (string) ( $request['redirect_to'] ?? $request['redirect'] ?? '' ), home_url('/') ) )
];
}
}
@@ -1471,7 +1509,7 @@
$username = wp_slash($username);
$email = wp_slash($email);
- if('yes' !== get_option( 'woocommerce_enable_myaccount_registration' ) && 'yes' !== get_option( 'users_can_register' )){
+ if(! ( function_exists( 'WC' ) && 'yes' === get_option( 'woocommerce_enable_myaccount_registration' ) ) && ! get_option( 'users_can_register' )){
return [
'type' => 'error',
'message' => __( '<strong>Error:</strong> This feature is not available.', 'lastudio-kit' ),
@@ -1591,22 +1629,6 @@
return $settings;
}
- public function e_shapes( $additional_shapes ){
- $lakit_shapes = [];
- $title = esc_html_x( 'LA-Kit Shape', 'Shapes', 'lastudio-kit' );
- for ($i = 1; $i <= 19; $i++){
- $k = $i < 10 ? '0' . $i : $i;
- $lakit_shapes['lakit-shape-' . $k] = [
- 'title' => $title . ' ' . $k,
- 'has_negative' => true,
- 'has_flip' => true,
- 'url' => lastudio_kit()->plugin_url('assets/shapes/custom-'.$k.'.svg'),
- 'path' => lastudio_kit()->plugin_path('assets/shapes/custom-'.$k.'.svg'),
- ];
- }
- return array_merge( $additional_shapes, $lakit_shapes );
- }
-
public function enqueue_frontend_scripts(){
if(!!lastudio_kit()->elementor()->assets_loader){
$this->register_assets();
--- a/lastudio-element-kit/includes/class-svg-manager.php
+++ b/lastudio-element-kit/includes/class-svg-manager.php
@@ -48,10 +48,41 @@
}
add_filter( 'upload_mimes', array( $this, 'allow_svg' ) );
+ add_filter( 'wp_handle_upload_prefilter', array( $this, 'sanitize_svg_upload' ) );
add_action( 'admin_head', array( $this, 'fix_svg_thumb_display' ) );
add_filter( 'wp_generate_attachment_metadata', array( $this, 'generate_svg_media_files_metadata' ), 10, 2 );
add_filter( 'wp_prepare_attachment_for_js', array( $this, 'wp_prepare_attachment_for_js' ), 10, 3 );
- add_filter( 'elementor/files/allow_unfiltered_upload', '__return_true' );
+ add_filter( 'elementor/files/allow_unfiltered_upload', function( $enabled ) {
+ return $enabled || current_user_can( 'unfiltered_html' );
+ } );
+ }
+
+ /**
+ * Strip scripts / event handlers from SVG files uploaded by users without `unfiltered_html`.
+ *
+ * @param array $file
+ * @return array
+ */
+ public function sanitize_svg_upload( $file ) {
+ if ( empty( $file['tmp_name'] ) || empty( $file['name'] ) ) {
+ return $file;
+ }
+ $ext = strtolower( pathinfo( $file['name'], PATHINFO_EXTENSION ) );
+ if ( ! in_array( $ext, [ 'svg', 'svgz' ], true ) ) {
+ return $file;
+ }
+ if ( current_user_can( 'unfiltered_html' ) ) {
+ return $file;
+ }
+ if ( 'svgz' === $ext || ! class_exists( 'ElementorCoreUtilsSvgSvg_Sanitizer' ) ) {
+ $file['error'] = esc_html__( 'Sorry, you are not allowed to upload this file type.', 'lastudio-kit' );
+ return $file;
+ }
+ $sanitizer = new ElementorCoreUtilsSvgSvg_Sanitizer();
+ if ( ! $sanitizer->sanitize_file( $file['tmp_name'] ) ) {
+ $file['error'] = esc_html__( 'This SVG file could not be sanitized.', 'lastudio-kit' );
+ }
+ return $file;
}
/**
--- a/lastudio-element-kit/includes/extensions/albums/dynamic-tags/tag.php
+++ b/lastudio-element-kit/includes/extensions/albums/dynamic-tags/tag.php
@@ -44,7 +44,7 @@
'lakit_popup_id',
[
'label' => esc_html__( 'Popup Template', 'lastudio-kit' ),
- 'type' => QueryControlModule::QUERY_CONTROL_ID,
+ 'type' => DynamicTagsModule::get_query_control_type(),
'autocomplete' => [
'object' => QueryControlModule::QUERY_OBJECT_LIBRARY_TEMPLATE,
'query' => [
@@ -65,7 +65,7 @@
'lakit_album_id',
[
'label' => esc_html__( 'Album ID', 'lastudio-kit' ),
- 'type' => QueryControlModule::QUERY_CONTROL_ID,
+ 'type' => DynamicTagsModule::get_query_control_type(),
'autocomplete' => [
'object' => 'post',
'query' => [
--- a/lastudio-element-kit/includes/extensions/albums/widget-templates/album-lists/global/index.php
+++ b/lastudio-element-kit/includes/extensions/albums/widget-templates/album-lists/global/index.php
@@ -146,8 +146,8 @@
echo '<div class="lakit-carousel__dots lakit-carousel__dots_'.esc_attr($this->get_id()).' swiper-pagination"></div>';
}
if (filter_var($this->get_settings_for_display('carousel_arrows'), FILTER_VALIDATE_BOOLEAN)) {
- echo sprintf('<div class="lakit-carousel__prev-arrow-%s lakit-arrow prev-arrow">%s</div>', esc_attr($this->get_id()), $this->_render_icon('carousel_prev_arrow', '%s', '', false)); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- echo sprintf('<div class="lakit-carousel__next-arrow-%s lakit-arrow next-arrow">%s</div>', esc_attr($this->get_id()), $this->_render_icon('carousel_next_arrow', '%s', '', false)); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ echo sprintf('<div class="lakit-carousel__prev-arrow-%s lakit-arrow prev-arrow">%s</div>', esc_attr($this->get_id()), $this->_render_icon( is_rtl() ? 'carousel_next_arrow' : 'carousel_prev_arrow', '%s', '', false)); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ echo sprintf('<div class="lakit-carousel__next-arrow-%s lakit-arrow next-arrow">%s</div>', esc_attr($this->get_id()), $this->_render_icon( is_rtl() ? 'carousel_prev_arrow' : 'carousel_next_arrow', '%s', '', false)); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
if (filter_var($this->get_settings_for_display('carousel_scrollbar'), FILTER_VALIDATE_BOOLEAN)) {
echo sprintf('<div class="lakit-carousel__scrollbar swiper-scrollbar lakit-carousel__scrollbar_%1$s"></div>', esc_attr($this->get_id()));
--- a/lastudio-element-kit/includes/extensions/albums/widget-templates/album-lists/global/loop-item.php
+++ b/lastudio-element-kit/includes/extensions/albums/widget-templates/album-lists/global/loop-item.php
@@ -10,7 +10,7 @@
$show_more = $this->get_settings_for_display('show_more');
$show_excerpt = $this->get_settings_for_display('show_excerpt');
$excerpt_length = $this->get_settings_for_display('excerpt_length');
-$title_html_tag = $this->get_settings_for_display('title_html_tag');
+$title_html_tag = lastudio_kit_helper()->validate_html_tag( $this->get_settings_for_display('title_html_tag') );
$show_play = $this->get_settings_for_display('show_play_album');
--- a/lastudio-element-kit/includes/extensions/albums/widget-templates/album-lists/global/loop-meta1.php
+++ b/lastudio-element-kit/includes/extensions/albums/widget-templates/album-lists/global/loop-meta1.php
@@ -42,7 +42,7 @@
break;
case 'custom_field':
if(!empty($meta['custom_field_key'])){
- $meta_value = get_post_meta(get_the_ID(), $meta['custom_field_key'], true);
+ $meta_value = LaStudio_Kit_Helper::get_public_post_meta( get_the_ID(), $meta['custom_field_key'] );
$item_type_class = 'post__custom_field';
}
break;
--- a/lastudio-element-kit/includes/extensions/albums/widget-templates/album-lists/global/loop-meta2.php
+++ b/lastudio-element-kit/includes/extensions/albums/widget-templates/album-lists/global/loop-meta2.php
@@ -42,7 +42,7 @@
break;
case 'custom_field':
if(!empty($meta['custom_field_key'])){
- $meta_value = get_post_meta(get_the_ID(), $meta['custom_field_key'], true);
+ $meta_value = LaStudio_Kit_Helper::get_public_post_meta( get_the_ID(), $meta['custom_field_key'] );
$item_type_class = 'post__custom_field';
}
break;
--- a/lastudio-element-kit/includes/extensions/albums/widget-templates/player/global/index.php
+++ b/lastudio-element-kit/includes/extensions/albums/widget-templates/player/global/index.php
@@ -5,6 +5,9 @@
$show_playlist = $this->get_settings_for_display('show_playlist');
$preset = $this->get_settings_for_display('preset');
+if ( ! in_array( $preset, [ 'type-1', 'type-2', 'type-3' ], true ) ) {
+ $preset = 'type-1';
+}
$configs = apply_filters('lastudio-kit/playlists/get_config', [], $album_ids);
$playlist_source = !empty($configs['sources']) ? $configs['sources'] : [];
--- a/lastudio-element-kit/includes/extensions/elementor/classes/query-control.php
+++ b/lastudio-element-kit/includes/extensions/elementor/classes/query-control.php
@@ -68,6 +68,8 @@
*/
public function ajax_posts_filter_autocomplete( array $data ) {
+ self::check_permission();
+
if(!empty($data['autocomplete'])){
return $this->ajax_posts_filter_autocomplete_new($data);
}
@@ -147,7 +149,7 @@
case 'author':
$query_params = [
- 'who' => 'authors',
+ 'capability' => [ 'edit_posts' ],
'has_published_posts' => true,
'fields' => [
'ID',
@@ -276,6 +278,8 @@
public function ajax_posts_control_value_titles( $request ) {
+ self::check_permission();
+
if(!empty($request['get_titles'])){
return $this->ajax_posts_control_value_titles_new($request);
}
@@ -331,7 +335,7 @@
case 'author':
$query_params = [
- 'who' => 'authors',
+ 'capability' => [ 'edit_posts' ],
'has_published_posts' => true,
'fields' => [
'ID',
@@ -414,6 +418,96 @@
return $results;
}
+ /**
+ * Only users who can edit posts may use the query control endpoints.
+ *
+ * @throws Exception
+ */
+ public static function check_permission() {
+ if ( ! current_user_can( 'edit_posts' ) ) {
+ throw new Exception( 'Access denied.' );
+ }
+ }
+
+ /**
+ * Reduce a client supplied query array to a safe subset of keys.
+ *
+ * @param mixed $query
+ * @return array
+ */
+ private function sanitize_client_query( $query ) {
+ $query = is_array( $query ) ? $query : [];
+ $clean = [];
+
+ if ( ! empty( $query['post_type'] ) ) {
+ $clean['post_type'] = is_array( $query['post_type'] ) ? array_map( 'sanitize_key', $query['post_type'] ) : sanitize_key( $query['post_type'] );
+ }
+
+ if ( ! empty( $query['taxonomy'] ) ) {
+ $clean['taxonomy'] = is_array( $query['taxonomy'] ) ? array_map( 'sanitize_key', $query['taxonomy'] ) : sanitize_key( $query['taxonomy'] );
+ }
+
+ if ( current_user_can( 'edit_others_posts' ) && ! empty( $query['post_status'] ) ) {
+ $clean['post_status'] = is_array( $query['post_status'] ) ? array_map( 'sanitize_key', $query['post_status'] ) : sanitize_key( $query['post_status'] );
+ }
+ else {
+ $clean['post_status'] = 'publish';
+ }
+
+ // Taxonomy filters (e.g. only "simple" products), limited to taxonomy / field / terms / operator.
+ if ( ! empty( $query['tax_query'] ) && is_array( $query['tax_query'] ) ) {
+ $tax_query = [];
+ foreach ( $query['tax_query'] as $k => $clause ) {
+ if ( 'relation' === $k && is_string( $clause ) ) {
+ $tax_query['relation'] = 'OR' === strtoupper( $clause ) ? 'OR' : 'AND';
+ continue;
+ }
+ if ( ! is_array( $clause ) || empty( $clause['taxonomy'] ) || ! is_string( $clause['taxonomy'] ) || ! taxonomy_exists( $clause['taxonomy'] ) || ! isset( $clause['terms'] ) ) {
+ continue;
+ }
+ $item = [
+ 'taxonomy' => sanitize_key( $clause['taxonomy'] ),
+ 'field' => isset( $clause['field'] ) && in_array( $clause['field'], [ 'term_id', 'slug', 'name', 'term_taxonomy_id' ], true ) ? $clause['field'] : 'term_id',
+ 'terms' => is_array( $clause['terms'] ) ? array_map( 'sanitize_text_field', $clause['terms'] ) : sanitize_text_field( $clause['terms'] ),
+ ];
+ if ( isset( $clause['operator'] ) && in_array( strtoupper( $clause['operator'] ), [ 'IN', 'NOT IN', 'AND', 'EXISTS', 'NOT EXISTS' ], true ) ) {
+ $item['operator'] = strtoupper( $clause['operator'] );
+ }
+ $tax_query[] = $item;
+ }
+ if ( ! empty( $tax_query ) ) {
+ $clean['tax_query'] = $tax_query;
+ }
+ }
+
+ // Allow Elementor's own template meta filters only.
+ if ( ! empty( $query['meta_query'] ) && is_array( $query['meta_query'] ) ) {
+ $meta_query = [];
+ foreach ( $query['meta_query'] as $k => $clause ) {
+ if ( 'relation' === $k && is_string( $clause ) ) {
+ $meta_query['relation'] = 'OR' === strtoupper( $clause ) ? 'OR' : 'AND';
+ continue;
+ }
+ if ( ! is_array( $clause ) || empty( $clause['key'] ) || ! is_string( $clause['key'] ) || 0 !== strpos( $clause['key'], '_elementor_' ) ) {
+ continue;
+ }
+ $item = [ 'key' => sanitize_key( $clause['key'] ) ];
+ if ( isset( $clause['value'] ) ) {
+ $item['value'] = is_array( $clause['value'] ) ? array_map( 'sanitize_text_field', $clause['value'] ) : sanitize_text_field( $clause['value'] );
+ }
+ if ( isset( $clause['compare'] ) && in_array( strtoupper( $clause['compare'] ), [ '=', '!=', 'IN', 'NOT IN', 'EXISTS', 'NOT EXISTS' ], true ) ) {
+ $item['compare'] = strtoupper( $clause['compare'] );
+ }
+ $meta_query[] = $item;
+ }
+ if ( ! empty( $meta_query ) ) {
+ $clean['meta_query'] = $meta_query;
+ }
+ }
+
+ return $clean;
+ }
+
private function get_titles_query_data( $data ) {
if ( empty( $data['get_titles'] ) || empty( $data['id'] ) || empty( $data['get_titles']['object'] ) ) {
return new WP_Error( self::GET_TITLES_ERROR_CODE, 'Empty or incomplete data' );
@@ -441,7 +535,8 @@
}
private function get_titles_query_for_post( $data ) {
- $query = isset($data['get_titles']['query']) ? $data['get_titles']['query'] : [];
+ $query = $this->sanitize_client_query( $data['get_titles']['query'] ?? [] );
+ unset( $query['taxonomy'] );
if ( empty( $query['post_type'] ) ) {
$query['post_type'] = 'any';
}
@@ -460,7 +555,10 @@
}
private function get_titles_query_for_tax( $data ) {
- $by_field = empty( $data['get_titles']['by_field'] ) ? 'term_taxonomy_id' : $data['get_titles']['by_field'];
+ $by_field = ( ! empty( $data['get_titles']['by_field'] ) && in_array( $data['get_titles']['by_field'], [ 'term_taxonomy_id', 'term_id', 'slug', 'name' ], true ) ) ? $data['get_titles']['by_field'] : 'term_taxonomy_id';
+ if ( 'term_id' === $by_field ) {
+ $by_field = 'include';
+ }
return [
$by_field => (array) $data['id'],
'hide_empty' => false,
@@ -469,7 +567,9 @@
private function get_titles_query_for_library_template( $data ) {
- $query = isset($data['get_titles']['query']) ? $data['get_titles']['query'] : [];
+ $query = $this->sanitize_client_query( $data['get_titles']['query'] ?? [] );
+ unset( $query['taxonomy'] );
+ $query['post__in'] = array_map( 'absint', (array) $data['id'] );
$query['post_type'] = ElementorTemplateLibrarySource_Local::CPT;
$query['orderby'] = 'meta_value';
@@ -484,23 +584,21 @@
private function get_titles_query_for_author( $data ) {
$query = $this->get_titles_query_for_user( $data );
- $query['who'] = 'authors';
+ $query['capability'] = [ 'edit_posts' ];
$query['has_published_posts'] = true;
return $query;
}
private function get_titles_query_for_user( $data ) {
- if(!empty($data['get_titles']['query'])){
- return $data['get_titles']['query'];
- }
+ // Never use a client supplied WP_User_Query.
$query = [
'fields' => [
'ID',
'display_name',
],
- 'include' => (array) $data['id'],
+ 'include' => array_map( 'absint', (array) $data['id'] ),
];
- if ( isset($data['get_titles']['display'] ) && 'detailed' === $data['get_titles']['display'] ) {
+ if ( isset($data['get_titles']['display'] ) && 'detailed' === $data['get_titles']['display'] && current_user_can( 'list_users' ) ) {
$query['fields'][] = 'user_email';
}
return $query;
@@ -635,18 +733,20 @@
if ( ! isset( $data['autocomplete']['query'] ) ) {
return new WP_Error( self::AUTOCOMPLETE_ERROR_CODE, 'Missing autocomplete[`query`] data' );
}
- $query = $data['autocomplete']['query'];
+ $query = $this->sanitize_client_query( $data['autocomplete']['query'] );
+ unset( $query['taxonomy'] );
if ( empty( $query['post_type'] ) ) {
$query['post_type'] = 'any';
}
$query['posts_per_page'] = -1;
- $query['s'] = $data['q'];
+ $query['s'] = sanitize_text_field( $data['q'] );
return $query;
}
private function autocomplete_query_for_library_template( $data ) {
- $query = $data['autocomplete']['query'];
+ $query = $this->sanitize_client_query( $data['autocomplete']['query'] ?? [] );
+ unset( $query['taxonomy'] );
$query['post_type'] = ElementorTemplateLibrarySource_Local::CPT;
$query['orderby'] = 'meta_value';
@@ -655,7 +755,7 @@