Hi,

My setup is a simple search api views (search api solr as backend). 2 fields: node title and body field. Keyword search is exposed.

Example:
The main body text contains "This is a test", in which the word "test" is a hyperlink to www.test.com - html format: "This is a <a href="www.test.com">test</a>".

When you search for "test" keyword, if the "test" in the above string is not a hyperlink, highlighting works fine, the word "test" is in bold. But if the word "test" is a hyperlink as described above, the href record "www.test.com" is also altered. It will become something like href="www.<strong>test</strong>.com" which messes up the hyper link.

Does anyone know how to sort this out? Maybe force the highlight processor to ignore href part?

Many thanks,
Long

Comments

longmtran’s picture

Issue summary: View changes
longmtran’s picture

Issue summary: View changes
longmtran’s picture

Issue summary: View changes
drunken monkey’s picture

Status: Active » Needs review
Issue tags: -Search API, -Search API processor, -search api highlight
StatusFileSize
new1.78 KB

Thanks for reporting this issue!
It seems we totally overlooked that when adding the Highlighting processor. Please see whether the attached patch fixes the problem!

Also, please read and respect the issue tag guidelines. Short summary: don't use them.

Status: Needs review » Needs work

The last submitted patch, 4: 2135697-4--highlighting_html_tags.patch, failed testing.

drunken monkey’s picture

Version: 7.x-1.9 » 7.x-1.x-dev
Status: Needs work » Needs review
drunken monkey’s picture

StatusFileSize
new1.78 KB

Re-attaching because test bot is stupid (or too clever).

Status: Needs review » Needs work

The last submitted patch, 7: 2135697-4--highlighting_html_tags.patch, failed testing.

drunken monkey’s picture

Status: Needs work » Needs review
StatusFileSize
new1.8 KB

Oh, OK, it isn't. Since I just committed a follow-up to #2168713: Warning: preg_match(): Unknown modifier '(' in SearchApiHighlight->createExcerpt() it seems this needed a re-roll. Patch attached!

drunken monkey’s picture

Status: Needs review » Fixed

  • Commit ca46ff9 on 7.x-1.x by drunken monkey:
    Issue #2135697 by drunken monkey: Fixed handling of HTML attributes in...

Status: Fixed » Closed (fixed)

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

drunken monkey’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
Component: Framework » Plugins
Status: Closed (fixed) » Patch (to be ported)

Needs to be ported to D8.

drunken monkey’s picture

Issue tags: +Novice
rosinegrean’s picture

Assigned: Unassigned » rosinegrean
rosinegrean’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new1.83 KB

I was not able to test this, due some errors, but the patch is straight forward.
I'll debug those errors separately.

Status: Needs review » Needs work

The last submitted patch, 16: 2135697-16--highlighting_html_tags.patch, failed testing.

The last submitted patch, 16: 2135697-16--highlighting_html_tags.patch, failed testing.

The last submitted patch, 16: 2135697-16--highlighting_html_tags.patch, failed testing.

The last submitted patch, 16: 2135697-16--highlighting_html_tags.patch, failed testing.

The last submitted patch, 16: 2135697-16--highlighting_html_tags.patch, failed testing.

drunken monkey’s picture

I can reproduce the test fails locally, though I cannot see what could cause them, either. But the patch definitely breaks the highlight tests.

mashermike’s picture

Status: Needs work » Needs review
StatusFileSize
new1.83 KB

The updated call to the highlightField function was passing the wrong variable.

rosinegrean’s picture

Status: Needs review » Reviewed & tested by the community

Yes, you are right @mashermike.
This looks good now.

  • drunken monkey committed ea3f677 on 8.x-1.x authored by prics
    Issue #2135697 by prics, mashermike: Fixed handling of HTML attributes...
drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Looks great, thanks a lot!
Committed.

Status: Fixed » Closed (fixed)

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