diff options
| author | Claude Paroz <claude@2xlibre.net> | 2013-05-23 14:00:17 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2013-05-23 14:01:27 +0200 |
| commit | b664cb818d2e5896df2763299ea2c61a9af069a8 (patch) | |
| tree | 008713cc92b26d6470b2465b0744aabd359644b3 /django/utils | |
| parent | 8c2fd050f80f528cc1609c1a7f16901194834831 (diff) | |
Fixed #19237 (again) - Made strip_tags consistent between Python versions
Diffstat (limited to 'django/utils')
| -rw-r--r-- | django/utils/html.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/django/utils/html.py b/django/utils/html.py index 573235092d..0d28c77a61 100644 --- a/django/utils/html.py +++ b/django/utils/html.py @@ -16,7 +16,7 @@ from django.utils.functional import allow_lazy from django.utils import six from django.utils.text import normalize_newlines -from .html_parser import HTMLParser +from .html_parser import HTMLParser, HTMLParseError # Configuration for urlize() function. @@ -136,13 +136,13 @@ class MLStripper(HTMLParser): def strip_tags(value): """Returns the given HTML with all tags stripped.""" s = MLStripper() - s.feed(value) - data = s.get_data() try: - res = s.close() - except Exception as e: - data += s.rawdata - return data + s.feed(value) + s.close() + except HTMLParseError: + return value + else: + return s.get_data() strip_tags = allow_lazy(strip_tags) def remove_tags(html, tags): |
