Refactor search string escaping to a helper function

[MAILPOET-3077]
This commit is contained in:
Rostislav Wolny
2020-09-24 15:14:28 +02:00
committed by Veljko V
parent cd5079efda
commit d026517ed9
5 changed files with 21 additions and 8 deletions

View File

@ -2,6 +2,7 @@
namespace MailPoet\Models;
use MailPoet\Util\Helpers;
use MailPoet\WP\Functions as WPFunctions;
/**
@ -88,7 +89,7 @@ class ScheduledTaskSubscriber extends Model {
->select('subscribers.first_name', 'firstName');
if (isset($data['search'])) {
$search = trim($data['search']);
$search = str_replace(['\\', '%', '_'], ['\\\\', '\\%', '\\_'], $search); // escape for 'LIKE'
$search = Helpers::escapeSearch($search);
if (strlen($search) === 0) {
return $query;
}