blakearchive / archive

GNU General Public License v2.0
5 stars 7 forks source link

html showing up in search results #526

Open ghost opened 7 years ago

ghost commented 7 years ago

@queryluke luke, do you know how to fix the problem of html showing up in search results? search 'span', for example, and click on the first result. notice the \<span> tags showing up.

queryluke commented 7 years ago

@ba001 This is similar problem to the issue in erdman.

Search terms get highlighted using the highlight filter. In short, that filter accepts 2 string variables: phrase and text. It runs over text and if it finds a matching string to phrase it replaces that with <span class="highlighted">$phrase</span>.

It does a bit more than that because it also breaks up the phrase to handle multiple words, remove OR or AND, etc.

So the issue here is that the text variable contains html elements. So: <span>Some content</span> becomes <<span class="highlighted">span</span>>Some content</<span class="highlighted">span</span>>

You'll have to mess around with the regex replacement on line 9 & 19

A pattern that doesn't match a string if it begins with < or </.