Skip to content

Commit 254b910

Browse files
committed
fixup! Deprecate the sanitizer and recommend Bleach
1 parent ba3fd73 commit 254b910

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

html5lib/filters/sanitizer.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
"""Deprecated from html5lib 1.1.
2+
3+
See `here <https://github.com/html5lib/html5lib-python/issues/443>`_ for information about its
4+
deprecation; `Bleach <https://github.com/mozilla/bleach>`_ is recommended as a replacement. Please
5+
let us know in the aforementioned issue if Bleach is unsuitable for your needs.
6+
7+
"""
18
from __future__ import absolute_import, division, unicode_literals
29

310
import re
@@ -12,13 +19,14 @@
1219
__all__ = ["Filter"]
1320

1421

15-
warnings.warn(
22+
__deprecation_msg = (
1623
"html5lib's sanitizer is deprecated; see " +
1724
"https://github.com/html5lib/html5lib-python/issues/443 and please let " +
18-
"us know if Bleach in unsuitable for your needs",
19-
DeprecationWarning
25+
"us know if Bleach is unsuitable for your needs"
2026
)
2127

28+
warnings.warn(__deprecation_msg, DeprecationWarning)
29+
2230
allowed_elements = frozenset((
2331
(namespaces['html'], 'a'),
2432
(namespaces['html'], 'abbr'),
@@ -759,12 +767,7 @@ def __init__(self,
759767
"""
760768
super(Filter, self).__init__(source)
761769

762-
warnings.warn(
763-
"html5lib's sanitizer is deprecated; see " +
764-
"https://github.com/html5lib/html5lib-python/issues/443 and please let " +
765-
"us know if Bleach in unsuitable for your needs",
766-
DeprecationWarning
767-
)
770+
warnings.warn(__deprecation_msg, DeprecationWarning)
768771

769772
self.allowed_elements = allowed_elements
770773
self.allowed_attributes = allowed_attributes

0 commit comments

Comments
 (0)