We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 58ae93a6 authored by Mike Cochrane's avatar Mike Cochrane

Don't highlight search terms inside url

parent a1515e54
......@@ -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, '<strong>\\1</strong>', $text);
/* Remove highlighting from inside links, loop incase multiple highlights in links */
$pattern = '/(href="[^"]*)<strong>('.implode('|',array_map('htmlspecialchars', $terms)).')<\/strong>([^"]*")/iU';
do {
$result = preg_replace($pattern, '\\1\\2\\3', $result, -1, $count);
} while ($count);
return $result;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment