From 53af279ec24d4272096d11ef77496fd59208ee2f Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Feb 2015 15:52:08 +0100 Subject: [PATCH] doc/lib: Fix search criteria not splitting "complex" search strings correctly refs #6630 --- modules/doc/library/Doc/Search/DocSearch.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/doc/library/Doc/Search/DocSearch.php b/modules/doc/library/Doc/Search/DocSearch.php index ab3a7cf64..36f249ed6 100644 --- a/modules/doc/library/Doc/Search/DocSearch.php +++ b/modules/doc/library/Doc/Search/DocSearch.php @@ -32,20 +32,24 @@ class DocSearch $this->input = $search = (string) $search; $criteria = array(); if (preg_match_all('/"(?P[^"]*)"/', $search, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) { - $unquoted = ''; + $unquoted = array(); $offset = 0; foreach ($matches as $match) { $fullMatch = $match[0]; $searchMatch = $match['search']; - $unquoted .= substr($search, $offset, $fullMatch[1] - $offset); - $offset += $fullMatch[1] + strlen($fullMatch[0]); + $unquoted[] = substr($search, $offset, $fullMatch[1] - $offset); + $offset = $fullMatch[1] + strlen($fullMatch[0]); if (strlen($searchMatch[0]) > 0) { $criteria[] = $searchMatch[0]; } } - $search = $unquoted . substr($search, $offset); + $unquoted[] = substr($search, $offset); + $search = implode(' ', $unquoted); } - $this->search = array_unique(array_merge($criteria, array_filter(explode(' ', trim($search))))); + $this->search = array_map( + 'strtolower', + array_unique(array_merge($criteria, array_filter(explode(' ', trim($search))))) + ); } /**