Commented code showing in search results?

Michael Purgar asked on October 17, 2016 21:38

A question regarding what shows in search results in Kentico 8: search results do not show any of the code from a page that comes up in results, markup or otherwise, UNLESS the code is wrapped in a comment tag. So while we are able to comment out information so it doesn't render on a page, the search result for that page is showing any kind of text wrapped in the usual <!-- COMMENTS LIKE THIS --> sort of tags.

Is there any way to keep search results from picking these up, while leaving them on the page for developers to see? Thanks in advance!

Recent Answers


Michal Samuhel answered on October 18, 2016 13:33

Hi Micheal,

This was a bug that was fixed in hotfix for v9.0.34:

Search - Smart search indexing HTML comments The smart search incorrectly indexed HTML comments when building Page indexes and then returned them in related search results.

0 votesVote for this answer Mark as a Correct answer

Michael Purgar answered on October 18, 2016 15:11

Is there a known fix for version 8.2.48? That's the platform we're on right now...

0 votesVote for this answer Mark as a Correct answer

Joshua Adams answered on October 18, 2016 16:14

The upgrade from 8.2 to 9 isn't very difficult. I would recommend doing that anyways for the security issue in rest requests that was fixed in a hotfix for 9. Just back up everything before, but if the best practices were followed for any customizations, you shouldn't have issues from what I have seen.

0 votesVote for this answer Mark as a Correct answer

Michal Samuhel answered on October 18, 2016 16:19

The hotfixes are released only for most recent version. The change was done inside DLL and there was a change in method PrepareContentValue that should have prepared formatted the output and put it into content field of the index.

0 votesVote for this answer Mark as a Correct answer

Michael Purgar answered on October 18, 2016 16:24

Hi Joshua -

If we assume for the time being that such an upgrade is not practical, is there a viable way to make some sort of fix in the version we currently use? I'm not trying to be difficult, but with the environment the platform is currently implemented in makes upgrading Kentico a non-starter at this time.

0 votesVote for this answer Mark as a Correct answer

Joshua Adams answered on October 18, 2016 16:27

I guess inside the transformation you could do a replace on the body text or whatever it returns for your smart search results transformations. Or you could make a custom macro method that removes them. You could find the index of then use those indexes to remove the substring.

0 votesVote for this answer Mark as a Correct answer

Michal Samuhel answered on October 19, 2016 09:24

Michael,

I was looking at changesets and there was a just a different overload used on one method to ensure that the comments are replaces as well. You can call this method in transformation with same results(or as Joshua suggests create a custom macro method that will be used on search results):

public static string StripTags(string htmlText, bool replaceEntities, bool replaceComments, string tagReplacement, string entitiesReplacement, string commentsReplacement);

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.