Skip to content

Commit c2c1791

Browse files
Anne MirasolCopilot
andauthored
Check for json_decode errors
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 29f7c7f commit c2c1791

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-webhook-handler.php‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@ private function process_checkout_order_approved( $event ) {
8686
* @return WC_Order|null
8787
*/
8888
private function get_wc_order( $custom_id ) {
89-
$data = json_decode( $custom_id );
89+
$data = json_decode( $custom_id );
90+
if ( json_last_error() !== JSON_ERROR_NONE ) {
91+
WC_Gateway_Paypal::log( 'Invalid JSON in custom ID: ' . wc_print_r( $custom_id, true ) );
92+
return null;
93+
}
9094
$order_id = $data->order_id ?? null;
9195
if ( ! $order_id ) {
9296
return null;

0 commit comments

Comments
 (0)