From 895e8529dc41d9bb4680e5c636d63194f2d65dd3 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 28 Jun 2016 13:12:09 -0700 Subject: [PATCH] CRM_Utils_QueryFormatter::parseWords - Split email addresses (from lcdweb) See also: NYSS #9692 --- CRM/Utils/QueryFormatter.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CRM/Utils/QueryFormatter.php b/CRM/Utils/QueryFormatter.php index bdbabea97e..6c48b1b385 100644 --- a/CRM/Utils/QueryFormatter.php +++ b/CRM/Utils/QueryFormatter.php @@ -319,7 +319,16 @@ class CRM_Utils_QueryFormatter { * @return array */ protected function parseWords($text) { - return explode(' ', preg_replace('/[ \r\n\t]+/', ' ', trim($text))); + //NYSS 9692 special handling for emails + if (preg_match('/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/', $text)) { + $parts = explode('@', $text); + $parts[1] = stristr($parts[1], '.', TRUE); + $text = implode(' ', $parts); + } + //CRM_Core_Error::debug_var('parseWords $text', $text); + + //NYSS also replace other occurrences of @ + return explode(' ', preg_replace('/[ \r\n\t\@]+/', ' ', trim($text))); } /** -- 2.25.1