diff --git a/django/utils/html.py b/django/utils/html.py
index 5732350..ebf97f8 100644
a
|
b
|
def strip_tags(value):
|
137 | 137 | """Returns the given HTML with all tags stripped.""" |
138 | 138 | s = MLStripper() |
139 | 139 | s.feed(value) |
140 | | data = s.get_data() |
141 | | try: |
142 | | res = s.close() |
143 | | except Exception as e: |
144 | | data += s.rawdata |
145 | | return data |
| 140 | return s.get_data() |
146 | 141 | strip_tags = allow_lazy(strip_tags) |
147 | 142 | |
148 | 143 | def remove_tags(html, tags): |
diff --git a/docs/ref/utils.txt b/docs/ref/utils.txt
index 14ae9aa..9f8b1f1 100644
a
|
b
|
escaping HTML.
|
566 | 566 | If ``value`` is ``"<b>Joel</b> <button>is</button> a <span>slug</span>"`` the |
567 | 567 | return value will be ``"Joel is a slug"``. |
568 | 568 | |
| 569 | .. versionchanged:: 1.6 |
| 570 | |
| 571 | For improved safety, ``strip_tags`` is now parser-based. That means that |
| 572 | the fed ``value`` should contain valid HTML. Typically, unmatched tags |
| 573 | might result in content disappearing. |
| 574 | |
| 575 | |
569 | 576 | .. function:: remove_tags(value, tags) |
570 | 577 | |
571 | 578 | Removes a space-separated list of [X]HTML tag names from the output. |
diff --git a/tests/utils_tests/test_html.py b/tests/utils_tests/test_html.py
index c3e9f7c..d9fbc6d 100644
a
|
b
|
class TestUtilsHtml(TestCase):
|
69 | 69 | ('<adf>a', 'a'), |
70 | 70 | ('</adf>a', 'a'), |
71 | 71 | ('<asdf><asdf>e', 'e'), |
72 | | ('hi, <f x', 'hi, <f x'), |
73 | | ('</fe', '</fe'), |
| 72 | ('hi, <f x', 'hi, '), |
| 73 | ('</fe', ''), |
74 | 74 | ('<x>b<y>', 'b'), |
75 | 75 | ('a<p onclick="alert(\'<test>\')">b</p>c', 'abc'), |
76 | 76 | ('a<p a >b</p>c', 'abc'), |