From 58ae93a621b1e5379f61cbfd5af1d7ac49b7dc15 Mon Sep 17 00:00:00 2001 From: Mike Cochrane Date: Sat, 19 Jul 2008 23:34:01 -0400 Subject: [PATCH] Don't highlight search terms inside url darcs-hash:20080720033401-533db-05bf2c9ebe988ebda6a295447a958af66571a088.gz --- actions/noticesearch.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/actions/noticesearch.php b/actions/noticesearch.php index eb33827799..29527c5672 100644 --- a/actions/noticesearch.php +++ b/actions/noticesearch.php @@ -139,8 +139,15 @@ class NoticesearchAction extends SearchAction { } function highlight($text, $terms) { + /* Highligh serach terms */ $pattern = '/('.implode('|',array_map('htmlspecialchars', $terms)).')/i'; $result = preg_replace($pattern, '\\1', $text); + + /* Remove highlighting from inside links, loop incase multiple highlights in links */ + $pattern = '/(href="[^"]*)('.implode('|',array_map('htmlspecialchars', $terms)).')<\/strong>([^"]*")/iU'; + do { + $result = preg_replace($pattern, '\\1\\2\\3', $result, -1, $count); + } while ($count); return $result; } }