From: Mike Cochrane Date: Sun, 20 Jul 2008 03:34:01 +0000 (-0400) Subject: Don't highlight search terms inside url X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=58ae93a621b1e5379f61cbfd5af1d7ac49b7dc15;p=quix0rs-gnu-social.git Don't highlight search terms inside url darcs-hash:20080720033401-533db-05bf2c9ebe988ebda6a295447a958af66571a088.gz --- 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; } }