From b497210f172617cd4f5eda37405ff3b79431b55b Mon Sep 17 00:00:00 2001 From: Adeel Khan Date: Mon, 22 Jan 2018 18:31:24 +0500 Subject: [PATCH] strip_all_tags_but_br_filter would return HTML safe string. Now returning HTML safe string to template instead of just bleaching string for br tags. LEARNER-3930 --- openedx/core/djangolib/markup.py | 4 ++-- openedx/core/djangolib/tests/test_markup.py | 9 +++++++++ scripts/tests/test_xss_linter.py | 15 +++++++++++++++ scripts/xss_linter.py | 3 +++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/openedx/core/djangolib/markup.py b/openedx/core/djangolib/markup.py index 0cea1d4af9..42ff88b26a 100644 --- a/openedx/core/djangolib/markup.py +++ b/openedx/core/djangolib/markup.py @@ -37,7 +37,7 @@ def HTML(html): # pylint: disable=invalid-name def strip_all_tags_but_br(string_to_strip): """ - Strips all tags from a string except
+ Strips all tags from a string except
and marks as HTML. Usage: <%page expression_filter="h"/> @@ -53,4 +53,4 @@ def strip_all_tags_but_br(string_to_strip): string_to_strip = decode.utf8(string_to_strip) string_to_strip = bleach.clean(string_to_strip, tags=['br'], strip=True) - return string_to_strip + return HTML(string_to_strip) diff --git a/openedx/core/djangolib/tests/test_markup.py b/openedx/core/djangolib/tests/test_markup.py index f8a347bace..6aafb86209 100644 --- a/openedx/core/djangolib/tests/test_markup.py +++ b/openedx/core/djangolib/tests/test_markup.py @@ -90,3 +90,12 @@ class FormatHtmlTest(unittest.TestCase): self.assertIn('
', rendered_template) self.assertNotIn('