• Welcome to Simple Machines Community Forum. Please login or sign up.
November 27, 2021, 04:42:59 AM

News:

Join the Facebook Fan Page.


Broken search result

Started by Sir Osis of Liver, November 19, 2021, 09:50:40 PM

Previous topic - Next topic

Sir Osis of Liver

Search returns borked topic title, split <strong> tags, only on this topic. Can't find it. >:(
"The best laid schemes o' mice an' men / Gang aft a-gley." - Robert Burns

Sir Osis of Liver

Thanks for all the suggestions. :P  Having studied this further, am able to replicate the glitch on test install.  The original topic is here, if you search the title 'The Mill on the Floss' from home page, you'll see the result 'The ong class="highlight">Millong> on the Floss'.  The problem is the title, if it's in a child board and contains 'll on', search result is scrambled.  Any title string that includes 'l on ' (i.e., testl on test) will search badly.  This appears to be a very obscure bug in the search function.
"The best laid schemes o' mice an' men / Gang aft a-gley." - Robert Burns

Sir Osis of Liver

It's in Search.php -


/// search glitch original
// $subject_highlighted = preg_replace('/(' . preg_quote($query, '/') . ')/i' . ($context['utf8'] ? 'u' : ''), '<strong class="highlight">$1</strong>', $subject_highlighted);

/// search glitch fix
$subject_highlighted = preg_replace('/(' . preg_quote($query, '/') . ')/i' . ($context['utf8'] ? 'u' : ''), '<span class="highlight">$1</span>', $subject_highlighted);


The <strong> tags are redundant, .highlight class includes bold -


/* Highlighted text - such as search results. */
.highlight
{
font-weight: bold;
color: #ff7200 !important;
font-size: 1.1em;
}


Don't know why it breaks the string, but corrected code seems to fix it.
"The best laid schemes o' mice an' men / Gang aft a-gley." - Robert Burns

live627

A similar bug has come up before which triggered the highlighting algorithm to be redone in 2.1.

Sir Osis of Liver

Is 2.0 still getting bug fixes?
"The best laid schemes o' mice an' men / Gang aft a-gley." - Robert Burns

Advertisement: