Skip to content

Commit e37202f

Browse files
committed
Removed filter + sanitizing POST string
1 parent 4ce48d4 commit e37202f

File tree

3 files changed

+4
-28
lines changed

3 files changed

+4
-28
lines changed

client/checkout/woopay/express-button/use-express-checkout-product-handler.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* External dependencies
33
*/
44
import validator from 'validator';
5-
import { applyFilters } from '@wordpress/hooks';
65

76
const useExpressCheckoutProductHandler = ( api ) => {
87
const getAttributes = () => {
@@ -105,24 +104,12 @@ const useExpressCheckoutProductHandler = ( api ) => {
105104
}
106105

107106
const addOnForm = document.querySelector( 'form.cart' );
108-
let allowedFieldNames = applyFilters(
109-
'wcpayPaymentRequestAllowedFieldNames',
110-
[]
111-
);
112-
// Ensure allowedFieldNames is an array.
113-
if ( ! Array.isArray( allowedFieldNames ) ) {
114-
allowedFieldNames = [ allowedFieldNames ];
115-
}
116107

117108
if ( addOnForm ) {
118109
const formData = new FormData( addOnForm );
119110

120111
formData.forEach( ( value, name ) => {
121-
if (
122-
/^addon-/.test( name ) ||
123-
/^wc_/.test( name ) ||
124-
allowedFieldNames.includes( name )
125-
) {
112+
if ( /^(addon-|wc_)/.test( name ) ) {
126113
if ( /\[\]$/.test( name ) ) {
127114
const fieldName = name.substring( 0, name.length - 2 );
128115

client/payment-request/index.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* External dependencies
44
*/
55
import { __ } from '@wordpress/i18n';
6-
import { applyFilters, doAction } from '@wordpress/hooks';
6+
import { doAction } from '@wordpress/hooks';
77
import { debounce } from 'lodash';
88
/**
99
* Internal dependencies
@@ -189,19 +189,8 @@ jQuery( ( $ ) => {
189189

190190
// Add addons data to the POST body
191191
const formData = $( 'form.cart' ).serializeArray();
192-
let allowedFieldNames = applyFilters(
193-
'wcpayPaymentRequestAllowedFieldNames',
194-
[]
195-
);
196-
// Ensure allowedFieldNames is an array.
197-
if ( ! Array.isArray( allowedFieldNames ) ) {
198-
allowedFieldNames = [ allowedFieldNames ];
199-
}
200192
$.each( formData, ( i, field ) => {
201-
if (
202-
allowedFieldNames.includes( field.name ) ||
203-
/^(addon-|wc_)/.test( field.name )
204-
) {
193+
if ( /^(addon-|wc_)/.test( field.name ) ) {
205194
if ( /\[\]$/.test( field.name ) ) {
206195
const fieldName = field.name.substring(
207196
0,

includes/class-wc-payments-payment-request-button-handler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,7 @@ public function ajax_get_selected_product_data() {
10621062
$product = wc_get_product( $product_id );
10631063
$variation_id = null;
10641064
$currency = get_woocommerce_currency();
1065-
$is_deposit = isset( $_POST['wc_deposit_option'] ) ? 'yes' === $_POST['wc_deposit_option'] : null;
1065+
$is_deposit = isset( $_POST['wc_deposit_option'] ) ? 'yes' === sanitize_text_field( wp_unslash( $_POST['wc_deposit_option'] ) ) : null;
10661066

10671067
if ( ! is_a( $product, 'WC_Product' ) ) {
10681068
/* translators: product ID */

0 commit comments

Comments
 (0)