From 3f3c8f34f1135f1ee4500bb7d471e084aaa8241c Mon Sep 17 00:00:00 2001 From: Jesse Pearson Date: Thu, 11 Jul 2024 11:52:59 -0300 Subject: [PATCH] Fix Documents API regex to allow documents with dashes in name to be viewed --- changelog/fix-9083-documents-api-regex | 4 ++++ includes/wc-payment-api/class-wc-payments-api-client.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelog/fix-9083-documents-api-regex diff --git a/changelog/fix-9083-documents-api-regex b/changelog/fix-9083-documents-api-regex new file mode 100644 index 00000000000..79d7ad4daf8 --- /dev/null +++ b/changelog/fix-9083-documents-api-regex @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Fix Documents API regex to allow documents with dashes in name to be viewed. diff --git a/includes/wc-payment-api/class-wc-payments-api-client.php b/includes/wc-payment-api/class-wc-payments-api-client.php index d1a07e720ab..b0247f6f8af 100644 --- a/includes/wc-payment-api/class-wc-payments-api-client.php +++ b/includes/wc-payment-api/class-wc-payments-api-client.php @@ -1795,7 +1795,7 @@ public function get_documents_summary( array $filters = [] ) { * @throws API_Exception - If not connected or request failed. */ public function get_document( $document_id ) { - if ( ! preg_match( '/^\w+$/', $document_id ) ) { + if ( ! preg_match( '/^[\w-]+$/', $document_id ) ) { throw new API_Exception( __( 'Route param validation failed.', 'woocommerce-payments' ), 'wcpay_route_validation_failure',