When I use search form of Geeklog with regular expression characters which are quoted by preg_quote function and visit hit pages from results, highlighted string is replaced with quoted one. For example, if I visit
we can see that highlighted string is replaced with "1\.4\.1" from "1.4.1".
Second, when I search with Japanese characters which are URL encoded, matched strings are never highlighted in hit pages.
Text Formatted Code
function COM_highlightQuery( $text, $query )
{
$query = urldecode(str_replace( '+', ' ', $query ));
// ugly workaround:
// Using the /e modifier in preg_replace will cause all double quotes to
// be returned as \" - so we replace all \" in the result with unescaped
// double quotes. Any actual \" in the original text therefore have to be
// turned into \\" first ...
$text = str_replace( '\\"', '\\\\"', $text );
$mywords = explode( ' ', $query );
foreach( $mywords as $searchword )
{
if( !empty( $searchword ))
{
$reg_searchword = preg_quote( str_replace( "'", "\'", $searchword ));
$text = preg_replace( '/(\>(((?>[^><]+)|(?R))*)\<)/ie', "preg_replace('/(?>$reg_searchword+)/i','<span class=\"highlight\">$searchword</span>','\\0')", '<!-- x -->' . $text . '<!-- x -->' );
}
}
// ugly workaround, part 2
$text = str_replace( '\\"', '"', $text );
return $text;
}