Skip to content

Commit

Permalink
harden order email filter
Browse files Browse the repository at this point in the history
  • Loading branch information
senadir committed Feb 19, 2025
1 parent 793bffd commit 9028b68
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions includes/Entities/Orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,14 @@ public function search( string $query ): array {
// Extract email from query if it's prefixed with "email:".
if ( str_starts_with( $query, 'email:' ) ) {
$parts = explode( ' ', $query, 2 );
$email = substr( $parts[0], 6 );
$args['billing_email'] = $email;
$email = trim( substr( $parts[0], 6 ) ); // Trim whitespace from email
if ( ! empty( $email ) ) { // Only set billing_email if not empty
$args['billing_email'] = sanitize_email( $email ); // Sanitize email
}
// Use the rest of the query (if any) for the 's' parameter
$args['s'] = isset( $parts[1] ) ? $parts[1] : '';
$args['s'] = isset( $parts[1] ) ? trim( $parts[1] ) : '';
} else {
$args['s'] = $query;
$args['s'] = trim( $query ); // Trim whitespace from general search query
}

$query = new \WC_Order_Query( $args );
Expand Down
2 changes: 1 addition & 1 deletion merchant-buddy.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Merchant Buddy
* Plugin URI: https://merchant-buddy.com/
* Description: Instantly available search palette for WooCommerce with instant search and keyboard shortcuts.
* Version: 1.0.0
* Version: 1.0.1
* Requires at least: 6.4
* Tested up to: 6.7.1
* Requires PHP: 7.4
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "merchant-buddy",
"version": "1.0.0",
"version": "1.0.1",
"description": "Merchant Buddy is a WooCommerce plugin that allows you to search for products, orders, and customers in the WordPress admin dashboard.",
"author": "Seghir Nadir",
"license": "GPL-2.0-or-later",
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: assassinateur
Tags: woocommerce, search, algolia, admin
Requires at least: 6.4
Tested up to: 6.7.1
Stable tag: 1.0.0
Stable tag: 1.0.1
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down

0 comments on commit 9028b68

Please sign in to comment.