CRM_Utils_QueryFormatter::parseWords - Split email addresses (from lcdweb)
authorTim Otten <totten@civicrm.org>
Tue, 28 Jun 2016 20:12:09 +0000 (13:12 -0700)
committerTim Otten <totten@civicrm.org>
Tue, 28 Jun 2016 20:24:02 +0000 (13:24 -0700)
See also: NYSS #9692

CRM/Utils/QueryFormatter.php

index bdbabea97e326aec367eca2f471f352187d83e3d..6c48b1b38547a04bfa82aa7fd07728f36b5876f8 100644 (file)
@@ -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)));
   }
 
   /**