Support » Plugin: Relevanssi - A Better Search » Bug with highlighting

  • Hey Mikko,

    Just wanted to mention I think I found a bug with highlighting; not exactly sure the cause, but it’s very easy to reproduce if you’d like to have a look:

    ->visit my site (
    ->search for “ 2.0” (the search box is at the upper right)
    ->view the first result (the post is called “ 2.0”).

    You’ll notice that it’s highlighting a bunch of “2”‘s in the content, that aren’t actually there; I’m thinking it has something to do with htmlentities or the like. For instance, wherever there should be an apostrophe, it shows “217;”, with the “2” highlighted.

    Just an FYI 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Mikko Saari


    Yeah, I know… There’s a bit of a bug with this, and there’s actually a solution for it in the code, commented out, because when somebody else tried it, the solution was worse than the problem.

    If you want to try it, go to lib/excerpts-highlights.php and uncomment these blocks of code:

    $highlight = get_option('relevanssi_highlight');
    	if ("none" != $highlight) {
    		if (!is_admin()) {
    			$content = html_entity_decode($content, ENT_QUOTES, 'UTF-8');
    			// html_entity_decode to avoid highlighting from breaking HTML entities

    (line 115, in relevanssi_create_excerpt())

    $excerpt = htmlentities($excerpt, ENT_QUOTES, 'UTF-8');
    	// return the HTML entities that were stripped before

    (line 359, in relevanssi_highlight_terms())

    Does that help?

    Whoa – that TOTALLY messed up the content 😛 Now the content is just html.

    Plugin Author Mikko Saari


    Well, yeah, that’s what the other guy said as well =) It did work on my site…

    Since that’s my best attempt so far to solve this problem, there’s little else I can do right now. This is something that needs to be fixed at some point, but at the moment I don’t have a solution.

    OK…not critical for me either, but I just thought you’d like to know about it as it can be *very* visible in some cases.

    Until you can come up with a permanent solution, perhaps you might just not allow numbers to be searched for, or maybe if it’s a number & strlen(numberAsStr) < someThreshold…

    Plugin Author Mikko Saari


    Well, if I do that, somebody is going to complain about it… But maybe I can add that limitation to highlighting. I’ll have to see.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Bug with highlighting’ is closed to new replies.