Skip to content

Commit 7a8673c

Browse files
jorgeatorresgithub-actions[bot]WooCommerce Botalbarinnielslange
authored
[dev] 9.8 → trunk sync (#55)
* Prep release/9.8 for 9.8 cycle (woocommerce#56031) Prep release/9.8 for 9.8 cycle with version bump to 9.8.0-beta.1 Co-authored-by: WooCommerce Bot <[email protected]> * Release: Prepare the changelog for 9.8 (woocommerce#56035) * Delete changelog files from 9.8 release * Update the readme files for the 9.8 release * Update release date --------- Co-authored-by: WooCommerce Bot <[email protected]> Co-authored-by: Jorge Torres <[email protected]> * Cherry pick 56047 into frozen release: release/9.8 (woocommerce#56057) Fix combine 415 403 (woocommerce#56047) * Secure “Generate coupon code” button * Secure “Export products” button * Secure “Import products” button * Secure inline error messages * Secure link inside inline error messages * Remove “onChangeShippingMethodSelector” * Add changelog message * Secure “Read more” button * Added changelog. * Added element creation to avoid appending text to jQuery Object. --------- Co-authored-by: Alba Rincón <[email protected]> Co-authored-by: Niels Lange <[email protected]> Co-authored-by: Paulo Arromba <[email protected]> * Cherry pick 56048 into frozen release: release/9.8 (woocommerce#56060) Remove decodeEntities from the product name used on cart & checkout (woocommerce#56048) revert using RawHTML because it renders an extra div inside the <a> tag Co-authored-by: Alba Rincón <[email protected]> Co-authored-by: Alex Florisca <[email protected]> * Prevent Fatal Error on malformed pagination query (woocommerce#56049) * Avoid fatal by casting page number to integer Cast page number to integer when generating aria-label to ensure proper number formatting * Add changefile(s) from automation for the following project(s): woocommerce --------- Co-authored-by: github-actions <[email protected]> * Fix email accent color causing invisible text in emails (woocommerce#56061) * Use theme button background color as accent color in emails * Add changelog * Update tests * Fix textdomain loading warning in woocommerce 9 80 beta 1 (woocommerce#56133) * Refactor Email Editor Integration Initialization from using FeaturesUtil to `get_option` Using FeaturesUtil::feature_is_enabled here triggers a Translation loading early warning message on WordPress 6.8 Beta * Add change log file * Delete Transients: avoid running statements without options_to_clear. (woocommerce#56136) * Delete Transients: avoid running statements without options_to_clear. * Add changefile(s) from automation for the following project(s): woocommerce * Delete Transients: adds test case. * Fixes spelling. * Fixes _wc_delete_transients call. * Linting. * Fix linter white space * Returns early. --------- Co-authored-by: cpap <[email protected]> Co-authored-by: github-actions <[email protected]> Co-authored-by: Tom Cafferkey <[email protected]> * Cherry pick e2e test fixes 56083 and 56121 to 9.8 (woocommerce#56163) * [e2e-utils] Update editor-canvas locator to support updates in Gutenberg nightly (woocommerce#56083) * [e2e tests] Fixes to support WP core 6.8 (woocommerce#56121) --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: WooCommerce Bot <[email protected]> Co-authored-by: Alba Rincón <[email protected]> Co-authored-by: Niels Lange <[email protected]> Co-authored-by: Paulo Arromba <[email protected]> Co-authored-by: Alex Florisca <[email protected]> Co-authored-by: Luigi Teschio <[email protected]> Co-authored-by: github-actions <[email protected]> Co-authored-by: Ján Mikláš <[email protected]> Co-authored-by: Oluwaseun Olorunsola <[email protected]> Co-authored-by: Harris Papazoglou <[email protected]> Co-authored-by: cpap <[email protected]> Co-authored-by: Tom Cafferkey <[email protected]> Co-authored-by: Adrian Moldovan <[email protected]>
1 parent 2b51d82 commit 7a8673c

24 files changed

+149
-89
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fix
3+
4+
Updated the editor canvas frame locator to support changes in Gutenberg 20.6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fix
3+
4+
Improved shortcode cart and checkout coupon notices by appending elements instead of text.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: minor
2+
Type: fix
3+
4+
Avoid fatal by casting page number to integer
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fix
3+
4+
Fix email accent color causing invisible text in emails
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fix
3+
4+
Fixes an error when `_wc_delete_transients` is called but there aren't any transients stored in DB to delete yet.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: update
3+
4+
Replaced concatenated string-based HTML elements in JS with createElement().
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fix
3+
4+
Fix an xss vulnerability in the cart & checkout blocks
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: tweak
3+
4+
Switch from using FeaturesUtil to get_option for the Email Editor Integration package

plugins/woocommerce/client/blocks/assets/js/base/components/product-name/index.tsx

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/**
22
* External dependencies
33
*/
4-
import { decodeEntities } from '@wordpress/html-entities';
54
import clsx from 'clsx';
65
import type { AnchorHTMLAttributes, HTMLAttributes } from 'react';
76

@@ -55,9 +54,6 @@ export const ProductName = ( {
5554
}: ProductNameProps ): JSX.Element => {
5655
const classes = clsx( 'wc-block-components-product-name', className );
5756
const DisabledTagName = disabledTagName as DisabledTagNameType;
58-
// This HTML is safe because the store API runs titles through `wp_kses_post()` which removes dangerous HTML tags.
59-
// Ref: https://github.com/woocommerce/woocommerce/blob/trunk/src/StoreApi/Schemas/V1/ProductSchema.php#L100
60-
const decodedName = decodeEntities( name );
6157

6258
if ( disabled ) {
6359
const disabledProps = props as HTMLAttributes<
@@ -69,7 +65,7 @@ export const ProductName = ( {
6965
{ ...disabledProps }
7066
// eslint-disable-next-line react/no-danger
7167
dangerouslySetInnerHTML={ {
72-
__html: decodedName,
68+
__html: name,
7369
} }
7470
/>
7571
);
@@ -82,7 +78,7 @@ export const ProductName = ( {
8278
{ ...props }
8379
// eslint-disable-next-line react/no-danger
8480
dangerouslySetInnerHTML={ {
85-
__html: decodedName,
81+
__html: name,
8682
} }
8783
style={ style }
8884
/>

plugins/woocommerce/client/blocks/assets/js/base/components/read-more/trim-html.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ export function trimHtml( html, options ) {
105105
row = charArr.slice( 0, cut ).join( '' ) + suffix;
106106

107107
if ( moreLink ) {
108-
row +=
109-
'<a href="' +
110-
moreLink +
111-
'" style="display:inline">' +
112-
moreText +
113-
'</a>';
108+
const link = document.createElement( 'a' );
109+
link.href = moreLink;
110+
link.style.display = 'inline';
111+
link.textContent = moreText;
112+
113+
row += link.outerHTML;
114114
}
115115

116116
sum = limit;

plugins/woocommerce/client/legacy/js/admin/meta-boxes-coupon.js

+13-8
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,19 @@ jQuery(function( $ ) {
3838
}
3939
},
4040

41-
/**
42-
* Insert generate coupon code button HTML.
43-
*/
44-
insert_generate_coupon_code_button: function() {
45-
$( '.post-type-shop_coupon' ).find( '#title' ).after(
46-
'<a href="#" class="button generate-coupon-code">' + woocommerce_admin_meta_boxes_coupon.generate_button_text + '</a>'
47-
);
48-
},
41+
/**
42+
* Insert generate coupon code button HTML.
43+
*/
44+
insert_generate_coupon_code_button: function () {
45+
const $title = $('.post-type-shop_coupon').find('#title');
46+
const button = document.createElement('a');
47+
button.href = '#';
48+
button.className = 'button generate-coupon-code';
49+
button.textContent =
50+
woocommerce_admin_meta_boxes_coupon.generate_button_text;
51+
52+
$title.after(button);
53+
},
4954

5055
/**
5156
* Generate a random coupon code

plugins/woocommerce/client/legacy/js/admin/wc-shipping-zone-methods.js

-6
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@
104104
$( document.body ).on( 'wc_backbone_modal_next_response', this.onAddShippingMethodSubmitted );
105105
$( document.body ).on( 'wc_backbone_modal_before_remove', this.onCloseConfigureShippingMethod );
106106
$( document.body ).on( 'wc_backbone_modal_back_response', this.onConfigureShippingMethodBack );
107-
$( document.body ).on( 'change', '.wc-shipping-zone-method-selector select', this.onChangeShippingMethodSelector );
108107
$( document.body ).on( 'click', '.wc-shipping-zone-postcodes-toggle', this.onTogglePostcodes );
109108
$( document.body ).on( 'wc_backbone_modal_validation', { view: this }, this.validateFormArguments );
110109
$( document.body ).on( 'wc_backbone_modal_loaded', { view: this }, this.onModalLoaded );
@@ -751,11 +750,6 @@
751750
}
752751
}
753752
},
754-
onChangeShippingMethodSelector: function() {
755-
var description = $( this ).find( 'option:selected' ).data( 'description' );
756-
$( this ).parent().find( '.wc-shipping-zone-method-description' ).remove();
757-
$( this ).after( '<div class="wc-shipping-zone-method-description">' + description + '</div>' );
758-
},
759753
onTogglePostcodes: function( event ) {
760754
event.preventDefault();
761755
var $tr = $( this ).closest( 'tr');

plugins/woocommerce/client/legacy/js/admin/woocommerce_admin.js

+12-14
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,20 @@
1717
.attr( 'href', woocommerce_admin.urls.add_product );
1818
}
1919
if ( woocommerce_admin.urls.export_products ) {
20-
$title_action.after(
21-
'<a href="' +
22-
woocommerce_admin.urls.export_products +
23-
'" class="page-title-action">' +
24-
woocommerce_admin.strings.export_products +
25-
'</a>'
26-
);
20+
const exportLink = document.createElement('a');
21+
exportLink.href = woocommerce_admin.urls.export_products;
22+
exportLink.className = 'page-title-action';
23+
exportLink.textContent = woocommerce_admin.strings.export_products;
24+
25+
$title_action.after(exportLink);
2726
}
2827
if ( woocommerce_admin.urls.import_products ) {
29-
$title_action.after(
30-
'<a href="' +
31-
woocommerce_admin.urls.import_products +
32-
'" class="page-title-action">' +
33-
woocommerce_admin.strings.import_products +
34-
'</a>'
35-
);
28+
const importLink = document.createElement('a');
29+
importLink.href = woocommerce_admin.urls.import_products;
30+
importLink.className = 'page-title-action';
31+
importLink.textContent = woocommerce_admin.strings.import_products;
32+
33+
$title_action.after(importLink);
3634
}
3735
} else {
3836
$title_action.hide();

plugins/woocommerce/client/legacy/js/frontend/cart.js

+18-16
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ jQuery( function ( $ ) {
135135
if ( $( '.woocommerce-checkout' ).length ) {
136136
$( document.body ).trigger( 'update_checkout' );
137137
}
138-
139-
// Store the old coupon error message and value before the
138+
139+
// Store the old coupon error message and value before the
140140
// .woocommerce-cart-form is replaced with the new form.
141141
var $old_coupon_field_val = $( '#coupon_code' ).val();
142142
var $old_coupon_error_msg = $( '#coupon_code' )
@@ -151,7 +151,7 @@ jQuery( function ( $ ) {
151151
if ( preserve_notices && $old_coupon_error_msg.length > 0 ) {
152152
var $new_coupon_field = $( '.woocommerce-cart-form' ).find( '#coupon_code' );
153153
var $new_coupon_field_wrapper = $new_coupon_field.closest( '.coupon' );
154-
154+
155155
$new_coupon_field.val( $old_coupon_field_val );
156156
// The coupon input with error needs to be focused before adding the live region
157157
// with the error message, otherwise the screen reader won't read it.
@@ -206,30 +206,32 @@ jQuery( function ( $ ) {
206206
return;
207207
}
208208

209-
var $coupon_error_el = '';
209+
var $coupon_error_el = html_element;
210210

211211
if ( typeof html_element === 'string' ) {
212212
var msg = $( $.parseHTML( html_element ) ).text().trim();
213-
213+
214214
if ( msg === '' ) {
215215
return;
216216
}
217-
218-
$coupon_error_el = $( '<p class="coupon-error-notice" id="coupon-error-notice">' + msg + '</p>' );
219-
} else {
220-
$coupon_error_el = html_element;
217+
218+
$coupon_error_el = $('<p>', {
219+
class: 'coupon-error-notice',
220+
id: 'coupon-error-notice',
221+
text: msg
222+
});
221223
}
222224

223225
if ( is_live_region ) {
224226
$coupon_error_el.attr( 'role', 'alert' );
225227
}
226-
228+
227229
$target.find( '#coupon_code' )
228230
.addClass( 'has-error' )
229231
.attr( 'aria-invalid', 'true' )
230232
.attr( 'aria-describedby', 'coupon-error-notice' );
231233
$target.append( $coupon_error_el );
232-
};
234+
};
233235

234236
/**
235237
* Object to handle AJAX calls for cart shipping changes.
@@ -280,7 +282,7 @@ jQuery( function ( $ ) {
280282
$target.attr( 'aria-expanded', $form.is( ':visible' ) ? 'true' : 'false' );
281283
}, 0 );
282284
} );
283-
285+
284286
$( 'select.country_to_state, input.country_to_state' ).trigger(
285287
'change'
286288
);
@@ -315,7 +317,7 @@ jQuery( function ( $ ) {
315317
dataType: 'html',
316318
success: function ( response ) {
317319
update_cart_totals_div( response );
318-
320+
319321
var newCurrentTarget = document.getElementById( event.currentTarget.id );
320322

321323
if ( newCurrentTarget ) {
@@ -600,17 +602,17 @@ jQuery( function ( $ ) {
600602
'.woocommerce-error, .woocommerce-message, .woocommerce-info, ' +
601603
'.is-error, .is-info, .is-success, .coupon-error-notice'
602604
).remove();
603-
605+
604606
// We only want to show coupon notices if they are not errors.
605607
// Coupon errors are shown under the input.
606608
if ( response.indexOf( 'woocommerce-error' ) === -1 && response.indexOf( 'is-error' ) === -1 ) {
607-
show_notice( response );
609+
show_notice( response );
608610
} else {
609611
var $coupon_wrapper = $text_field.closest( '.coupon' );
610612

611613
if ( $coupon_wrapper.length > 0 ) {
612614
show_coupon_error( response, $coupon_wrapper, false );
613-
}
615+
}
614616
}
615617

616618
$( document.body ).trigger( 'applied_coupon', [

plugins/woocommerce/client/legacy/js/frontend/checkout.js

+32-16
Original file line numberDiff line numberDiff line change
@@ -621,29 +621,39 @@ jQuery( function( $ ) {
621621
$( document.body ).trigger( 'checkout_error' , [ error_message ] );
622622
},
623623
wrapMessagesInsideLink: function( $msgs ) {
624-
$( 'li[data-id]', $msgs ).each( function() {
625-
var $this = $( this );
626-
627-
$this.wrapInner( '<a href="#' + $this.attr( 'data-id' ) + '"></a>' );
624+
$msgs.find( 'li[data-id]' ).each( function() {
625+
const $this = $( this );
626+
const dataId = $this.attr( 'data-id' );
627+
if ( dataId ) {
628+
const $link = $('<a>', {
629+
href: '#' + dataId,
630+
html: $this.html()
631+
} );
632+
$this.empty().append( $link );
633+
}
628634
} );
629635

630636
return $msgs;
631637
},
632638
show_inline_errors: function( $messages ) {
633639
$messages.find( 'li[data-id]' ).each( function() {
634-
var $this = $( this );
635-
var dataId = $this.attr( 'data-id' );
636-
var $field = $( '#' + dataId );
640+
const $this = $( this );
641+
const dataId = $this.attr( 'data-id' );
642+
const $field = $( '#' + dataId );
637643

638644
if ( $field.length === 1 ) {
639-
var descriptionId = dataId + '_description';
640-
var msg = $this.text().trim();
641-
var $formRow = $field.closest( '.form-row' );
642-
643-
$formRow.append( '<p id="' + descriptionId + '" class="checkout-inline-error-message">' + msg + '</p>' );
644-
$field
645-
.attr( 'aria-describedby', descriptionId )
646-
.attr( 'aria-invalid', 'true' );
645+
const descriptionId = dataId + '_description';
646+
const msg = $this.text().trim();
647+
const $formRow = $field.closest( '.form-row' );
648+
649+
const errorMessage = document.createElement( 'p' );
650+
errorMessage.id = descriptionId;
651+
errorMessage.className = 'checkout-inline-error-message';
652+
errorMessage.textContent = msg;
653+
654+
$formRow.appendChild( errorMessage );
655+
$field.setAttribute( 'aria-describedby', descriptionId );
656+
$field.setAttribute( 'aria-invalid', 'true' );
647657
}
648658
} );
649659
},
@@ -695,7 +705,13 @@ jQuery( function( $ ) {
695705
.addClass( 'has-error' )
696706
.attr( 'aria-invalid', 'true' )
697707
.attr( 'aria-describedby', 'coupon-error-notice' );
698-
$target.append( '<span class="coupon-error-notice" id="coupon-error-notice" role="alert">' + msg + '</span>' );
708+
709+
$('<span>', {
710+
class: 'coupon-error-notice',
711+
id: 'coupon-error-notice',
712+
role: 'alert',
713+
text: msg
714+
}).appendTo($target);
699715
},
700716
remove_coupon_error: function( evt ) {
701717
$( evt.currentTarget )

plugins/woocommerce/includes/wc-core-functions.php

+8-3
Original file line numberDiff line numberDiff line change
@@ -2723,13 +2723,13 @@ function _wc_delete_transients( $transients ) {
27232723
}
27242724

27252725
// Limit the number of items in a single query to avoid exceeding database query parameter limits.
2726-
if ( count( $transients) > 199 ) {
2726+
if ( count( $transients ) > 199 ) {
27272727
// Process in smaller chunks to reduce memory usage.
27282728
$chunks = array_chunk( $transients, 100 );
27292729
$success = true;
27302730

27312731
foreach ( $chunks as $chunk ) {
2732-
$result = wc_delete_transients( $chunk );
2732+
$result = _wc_delete_transients( $chunk );
27332733
if ( ! $result ) {
27342734
$success = false;
27352735
}
@@ -2754,6 +2754,11 @@ function _wc_delete_transients( $transients ) {
27542754
);
27552755
}
27562756

2757+
if ( empty( $options_to_clear ) ) {
2758+
// If there are no options to clear, return true immediately.
2759+
return true;
2760+
}
2761+
27572762
// Use a single query for better performance.
27582763
$wpdb->query(
27592764
$wpdb->prepare(
@@ -2764,7 +2769,7 @@ function _wc_delete_transients( $transients ) {
27642769

27652770
// Lets clear our options data from the cache.
27662771
// We can batch delete if available, introduced in WP 6.0.0.
2767-
if ( ! wp_installing() && ! empty( $options_to_clear ) ) {
2772+
if ( ! wp_installing() ) {
27682773
if ( function_exists( 'wp_cache_delete_multiple' ) ) {
27692774
wp_cache_delete_multiple( $options_to_clear, 'options' );
27702775
} else {

plugins/woocommerce/includes/wc-template-functions.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4411,7 +4411,7 @@ function wc_add_aria_label_to_pagination_numbers( $html, $args ) {
44114411
continue;
44124412
}
44134413

4414-
$p->set_attribute( 'aria-label', $page_text . ' ' . number_format_i18n( $n ) );
4414+
$p->set_attribute( 'aria-label', $page_text . ' ' . number_format_i18n( (int) $n ) );
44154415
++$n;
44164416
}
44174417

0 commit comments

Comments
 (0)