--- a/Allura/allura/lib/search.py
+++ b/Allura/allura/lib/search.py
@@ -20,6 +20,7 @@
from logging import getLogger
import markdown
+import jinja2
from pylons import tmpl_context as c, app_globals as g
from pysolr import SolrError
@@ -34,6 +35,11 @@
# if index() returned doc without text, assume empty text
if not doc.get('text'):
doc['text'] = ''
+ # Convert text to plain text (It usually contains markdown markup).
+ # To do so, we convert markdown into html, and then strip all html tags.
+ text = doc['text']
+ text = g.markdown.convert(text)
+ doc['text'] = jinja2.Markup.escape(text).striptags()
return doc
class SearchError(SolrError):