From 9dc9995e4c70791b8dc1dca4d0492dbcb3ea184c Mon Sep 17 00:00:00 2001 From: Luan Date: Wed, 30 Oct 2013 15:09:18 -0200 Subject: [PATCH] Forcing escape of text_block on highlights --- src/colab/utils/highlighting.py | 7 +++++++ 1 file changed, 7 insertions(+), 0 deletions(-) diff --git a/src/colab/utils/highlighting.py b/src/colab/utils/highlighting.py index 353d84b..8f41b7c 100644 --- a/src/colab/utils/highlighting.py +++ b/src/colab/utils/highlighting.py @@ -1,8 +1,15 @@ from haystack.utils import Highlighter from django.conf import settings +from django.utils.html import escape, strip_tags class ColabHighlighter(Highlighter): + def highlight(self, text_block): + self.text_block = escape(strip_tags(text_block)) + highlight_locations = self.find_highlightable_words() + start_offset, end_offset = self.find_window(highlight_locations) + return self.render_html(highlight_locations, start_offset, end_offset) + def find_window(self, highlight_locations): """Getting the HIGHLIGHT_NUM_CHARS_BEFORE_MATCH setting to find how many characters before the first word found should -- libgit2 0.21.2