Allow built in payment method descriptions to contain HTML when rendered on the block checkout (#42706)

This commit is contained in:
Mike Jolley 2023-12-13 15:49:29 +00:00 committed by GitHub
commit db9be95f5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 4 deletions

View File

@ -5,6 +5,8 @@ import { registerPaymentMethod } from '@woocommerce/blocks-registry';
import { __ } from '@wordpress/i18n';
import { getPaymentMethodData } from '@woocommerce/settings';
import { decodeEntities } from '@wordpress/html-entities';
import { sanitizeHTML } from '@woocommerce/utils';
import { RawHTML } from '@wordpress/element';
/**
* Internal dependencies
@ -19,7 +21,7 @@ const label = decodeEntities( settings?.title || '' ) || defaultLabel;
* Content component
*/
const Content = () => {
return decodeEntities( settings.description || '' );
return <RawHTML>{ sanitizeHTML( settings.description || '' ) }</RawHTML>;
};
/**

View File

@ -5,6 +5,8 @@ import { registerPaymentMethod } from '@woocommerce/blocks-registry';
import { __ } from '@wordpress/i18n';
import { getPaymentMethodData } from '@woocommerce/settings';
import { decodeEntities } from '@wordpress/html-entities';
import { sanitizeHTML } from '@woocommerce/utils';
import { RawHTML } from '@wordpress/element';
/**
* Internal dependencies
@ -19,7 +21,7 @@ const label = decodeEntities( settings?.title || '' ) || defaultLabel;
* Content component
*/
const Content = () => {
return decodeEntities( settings.description || '' );
return <RawHTML>{ sanitizeHTML( settings.description || '' ) }</RawHTML>;
};
/**

View File

@ -5,6 +5,8 @@ import { registerPaymentMethod } from '@woocommerce/blocks-registry';
import { __ } from '@wordpress/i18n';
import { getPaymentMethodData } from '@woocommerce/settings';
import { decodeEntities } from '@wordpress/html-entities';
import { sanitizeHTML } from '@woocommerce/utils';
import { RawHTML } from '@wordpress/element';
/**
* Internal dependencies
@ -19,7 +21,7 @@ const label = decodeEntities( settings?.title || '' ) || defaultLabel;
* Content component
*/
const Content = () => {
return decodeEntities( settings.description || '' );
return <RawHTML>{ sanitizeHTML( settings.description || '' ) }</RawHTML>;
};
/**

View File

@ -5,6 +5,8 @@ import { registerPaymentMethod } from '@woocommerce/blocks-registry';
import { __ } from '@wordpress/i18n';
import { getPaymentMethodData, WC_ASSET_URL } from '@woocommerce/settings';
import { decodeEntities } from '@wordpress/html-entities';
import { sanitizeHTML } from '@woocommerce/utils';
import { RawHTML } from '@wordpress/element';
/**
* Internal dependencies
@ -17,7 +19,7 @@ const settings = getPaymentMethodData( 'paypal', {} );
* Content component
*/
const Content = () => {
return decodeEntities( settings.description || '' );
return <RawHTML>{ sanitizeHTML( settings.description || '' ) }</RawHTML>;
};
const paypalPaymentMethod = {

View File

@ -0,0 +1,4 @@
Significance: patch
Type: update
Allow built in payment method descriptions to contain HTML when rendered on the block checkout.

View File

@ -0,0 +1,4 @@
Significance: patch
Type: update
Allow built in payment method descriptions to contain HTML when rendered on the block checkout.