Problem/Motivation

The problem is in the code of the SearchApiHighlight::highlightField() method.

Example:

$text = 'Lorem ipsum dolor sit amet keyword';
$keys = ' keyword '; // After implode().

Highlighting prefix: <strong>
Highlighting suffix: </strong>

Result of highlighting: Lorem ipsum dolor sit amet<strong> keyword </strong

Proposed resolution

Strip whitespace from the beginning and end of a keyword.

Comments

WalkingDexter created an issue. See original summary.

walkingdexter’s picture

Patch with the proposed resolution.

walkingdexter’s picture

Status: Active » Needs review
drunken monkey’s picture

StatusFileSize
new792 bytes

Thanks a lot for reporting this!
I’m not quite sure where those spaces would come from, but it does look possible, and of course they should be removed.
However, I don’t think that’s the right spot to fix this. Seems better to do that right at the beginning, when extracting the used fulltext keywords. Please try if the attached patch works for you, too!

walkingdexter’s picture

Status: Needs review » Reviewed & tested by the community

Yep, patch #4 works for me. Thanks!

  • drunken monkey committed aedd433 on 7.x-1.x
    Issue #3056882 by drunken monkey, WalkingDexter: Fixed highlighting in...
drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Good to hear, thanks a lot for testing and reporting back!
Committed.
Thanks again!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.