quote match terms

darcs-hash:20080718183534-84dde-a8cdb4cbcb3eb67152eb74179e3b00061e2287cf.gz
This commit is contained in:
Evan Prodromou 2008-07-18 14:35:34 -04:00
parent f50bc70445
commit 7853df51ce

View File

@ -115,7 +115,8 @@ class PeoplesearchAction extends SearchAction {
} }
function highlight($text, $terms) { function highlight($text, $terms) {
$pattern = '/('.implode('|',array_map('htmlspecialchars', $terms)).')/i'; $terms = array_map('preg_quote', array_map('htmlspecialchars', $terms));
$pattern = '/('.implode('|',$terms).')/i';
$result = preg_replace($pattern, '<strong>\\1</strong>', htmlspecialchars($text)); $result = preg_replace($pattern, '<strong>\\1</strong>', htmlspecialchars($text));
return $result; return $result;
} }