Hello!

I use 2 processors: html_filter and highlight on my website. Order of these processors is:

  1. html_filter
  2. highlight

My highlight processor adds the prefix
<strong class="highlighting-keywords">
and suffix
</srong>
around keywords.

When I search a word "test" on my website, I see many <strong> tags on a search result page, i.e.

<h3>This is a &lt;strong&gt;<strong class="highlighting-keywords">test</strong>&lt;/strong&gt; title of node</h3>

  1. Solr sends search results with the tag strong around keywords
  2. Then highlight processor calls check_plain and adds the tag strong around keywords.

I see the function getFulltextFields() calls search_api_get_sanitized_field_values() and use check_plain() for search result.
It is very security, but users see many tags on the search result page. Maybe we will strip all tags?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

michael.krainiuk created an issue. See original summary.

mikhailkrainiuk’s picture

Issue summary: View changes
mikhailkrainiuk’s picture

Status: Active » Needs review
FileSize
1.07 KB

I see a Solr server sends result without tags, except tag <strong> around keywords.

If highlight processor adds <strong> tags around keywords, we can strip all other tags from search results.
There is a patch to strip tags in search results before highlight words. Review it, please.

mikhailkrainiuk’s picture

Issue summary: View changes
drunken monkey’s picture

Status: Needs review » Postponed (maintainer needs more info)
Issue tags: -check_plain, -tags

If you've configured Solr to highlight your field values, don't also use the "Highlight" processor. It's either one or the other.
Please try with only Solr and report back whether that works.

PS: It seems you (like many others – it's really easy to misinterpret) are confused by the "Issue tags" field. As the guidelines state, they aren't meant for free text tags related to the issue, but only for specific categorization purposes, usually by module maintainers.
So, if you aren't sure your current usage is correct, please just leave the field empty.

drunken monkey’s picture

Project: Search API » Search API Solr
Component: General code » Code
Status: Postponed (maintainer needs more info) » Needs review
FileSize
1.62 KB

Since a lot of people reported this problem over the years, maybe it's time to add a note to the description of the server option to point this out.

drunken monkey’s picture

Could someone please give this a short look and tell me if they think the phrasing is OK? Then I can commit and hopefully keep some people from making this mistake in the future.

Sardis’s picture

Status: Needs review » Reviewed & tested by the community

@drunken_monkey
Looks good to me.

  • drunken monkey committed 291ff8d on 7.x-1.x
    Issue #2772199 by drunken monkey: Added a warning to the description for...
drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Good to hear, thanks for reviewing!
Committed.

Status: Fixed » Closed (fixed)

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