Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecated messages on PHP 8.2 from using FILTER_SANITIZE_STRING #3144

Merged
merged 3 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Fix - Resgister script on the checkout page only when the gateway is enabled.
* Tweak - Allow to enable/disable payment methods irrespective of currency requirement.
* Add - Include WeChat Pay as a payment method for stores using the updated checkout experience.
* Fix - Deprecation errors on PHP 8.2 caused by using the deprecated constant FILTER_SANITIZE_STRING.

= 8.3.0 - 2024-05-23 =
* Add - Add a new dismissible banner to promote Stripe products to the settings page.
Expand Down
6 changes: 3 additions & 3 deletions includes/class-wc-stripe-customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ protected function generate_customer_request( $args = [] ) {
$defaults['name'] = $billing_full_name;
}
} else {
$billing_first_name = isset( $_POST['billing_first_name'] ) ? filter_var( wp_unslash( $_POST['billing_first_name'] ), FILTER_SANITIZE_STRING ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
$billing_last_name = isset( $_POST['billing_last_name'] ) ? filter_var( wp_unslash( $_POST['billing_last_name'] ), FILTER_SANITIZE_STRING ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
$billing_first_name = isset( $_POST['billing_first_name'] ) ? filter_var( wp_unslash( $_POST['billing_first_name'] ), FILTER_SANITIZE_SPECIAL_CHARS ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
$billing_last_name = isset( $_POST['billing_last_name'] ) ? filter_var( wp_unslash( $_POST['billing_last_name'] ), FILTER_SANITIZE_SPECIAL_CHARS ) : ''; // phpcs:ignore WordPress.Security.NonceVerification

// translators: %1$s First name, %2$s Second name.
$description = sprintf( __( 'Name: %1$s %2$s, Guest', 'woocommerce-gateway-stripe' ), $billing_first_name, $billing_last_name );
Expand All @@ -186,7 +186,7 @@ protected function generate_customer_request( $args = [] ) {
if ( $user ) {
$defaults['address'][ $key ] = get_user_meta( $user->ID, $field, true );
} else {
$defaults['address'][ $key ] = isset( $_POST[ $field ] ) ? filter_var( wp_unslash( $_POST[ $field ] ), FILTER_SANITIZE_STRING ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
$defaults['address'][ $key ] = isset( $_POST[ $field ] ) ? filter_var( wp_unslash( $_POST[ $field ] ), FILTER_SANITIZE_SPECIAL_CHARS ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
}
}

Expand Down
16 changes: 8 additions & 8 deletions includes/payment-methods/class-wc-stripe-payment-request.php
Original file line number Diff line number Diff line change
Expand Up @@ -1172,15 +1172,15 @@ public function ajax_get_shipping_options() {
$shipping_address = filter_input_array(
INPUT_POST,
[
'country' => FILTER_SANITIZE_STRING,
'state' => FILTER_SANITIZE_STRING,
'postcode' => FILTER_SANITIZE_STRING,
'city' => FILTER_SANITIZE_STRING,
'address' => FILTER_SANITIZE_STRING,
'address_2' => FILTER_SANITIZE_STRING,
'country' => FILTER_SANITIZE_SPECIAL_CHARS,
'state' => FILTER_SANITIZE_SPECIAL_CHARS,
'postcode' => FILTER_SANITIZE_SPECIAL_CHARS,
'city' => FILTER_SANITIZE_SPECIAL_CHARS,
'address' => FILTER_SANITIZE_SPECIAL_CHARS,
'address_2' => FILTER_SANITIZE_SPECIAL_CHARS,
]
);
$product_view_options = filter_input_array( INPUT_POST, [ 'is_product_page' => FILTER_SANITIZE_STRING ] );
$product_view_options = filter_input_array( INPUT_POST, [ 'is_product_page' => FILTER_SANITIZE_SPECIAL_CHARS ] );
$should_show_itemized_view = ! isset( $product_view_options['is_product_page'] ) ? true : filter_var( $product_view_options['is_product_page'], FILTER_VALIDATE_BOOLEAN );

$data = $this->get_shipping_options( $shipping_address, $should_show_itemized_view );
Expand Down Expand Up @@ -1284,7 +1284,7 @@ public function ajax_update_shipping_method() {

WC()->cart->calculate_totals();

$product_view_options = filter_input_array( INPUT_POST, [ 'is_product_page' => FILTER_SANITIZE_STRING ] );
$product_view_options = filter_input_array( INPUT_POST, [ 'is_product_page' => FILTER_SANITIZE_SPECIAL_CHARS ] );
$should_show_itemized_view = ! isset( $product_view_options['is_product_page'] ) ? true : filter_var( $product_view_options['is_product_page'], FILTER_VALIDATE_BOOLEAN );

$data = [];
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,6 @@ If you get stuck, you can ask for help in the Plugin Forum.
* Fix - Resgister script on the checkout page only when the gateway is enabled.
* Tweak - Allow to enable/disable payment methods irrespective of currency requirement.
* Add - Include WeChat Pay as a payment method for stores using the updated checkout experience.
* Fix - Deprecation errors on PHP 8.2 caused by using the deprecated constant FILTER_SANITIZE_STRING.

[See changelog for all versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/trunk/changelog.txt).
Loading