File tree Expand file tree Collapse file tree 4 files changed +44
-19
lines changed Expand file tree Collapse file tree 4 files changed +44
-19
lines changed Original file line number Diff line number Diff line change @@ -11,11 +11,18 @@ Breaking changes:
11
11
* Drop support for Python 3.3. (#358)
12
12
* Drop support for Python 3.4. (#421)
13
13
14
+ Deprecations:
15
+
16
+ * Deprecate the ``html5lib `` sanitizer (``html5lib.serialize(sanitize=True) `` and
17
+ ``html5lib.filters.sanitizer ``). We recommend users migrate to `Bleach
18
+ <https://github.com/mozilla/bleach> `. Please let us know if Bleach doesn't suffice for your
19
+ use. (#443)
20
+
14
21
Other changes:
15
22
16
- * Try to import from `collections.abc ` to remove DeprecationWarning and ensure
17
- `html5lib ` keeps working in future Python versions. (#403)
18
- * Drop optional `datrie ` dependency. (#442)
23
+ * Try to import from `` collections.abc ` ` to remove DeprecationWarning and ensure
24
+ `` html5lib ` ` keeps working in future Python versions. (#403)
25
+ * Drop optional `` datrie ` ` dependency. (#442)
19
26
20
27
21
28
1.0.1
Original file line number Diff line number Diff line change 1
1
from __future__ import absolute_import , division , unicode_literals
2
2
3
3
import re
4
+ import warnings
4
5
from xml .sax .saxutils import escape , unescape
5
6
6
7
from six .moves import urllib_parse as urlparse
11
12
__all__ = ["Filter" ]
12
13
13
14
15
+ warnings .warn (
16
+ "html5lib's sanitizer is deprecated; see " +
17
+ "https://github.com/html5lib/html5lib-python/issues/443 and please let " +
18
+ "us know if Bleach in unsuitable for your needs" ,
19
+ DeprecationWarning
20
+ )
21
+
14
22
allowed_elements = frozenset ((
15
23
(namespaces ['html' ], 'a' ),
16
24
(namespaces ['html' ], 'abbr' ),
@@ -750,6 +758,14 @@ def __init__(self,
750
758
751
759
"""
752
760
super (Filter , self ).__init__ (source )
761
+
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
+ )
768
+
753
769
self .allowed_elements = allowed_elements
754
770
self .allowed_attributes = allowed_attributes
755
771
self .allowed_css_properties = allowed_css_properties
Original file line number Diff line number Diff line change @@ -27,14 +27,15 @@ def runtest(self):
27
27
expected = self .test ["output" ]
28
28
29
29
parsed = parseFragment (input )
30
- serialized = serialize (parsed ,
31
- sanitize = True ,
32
- omit_optional_tags = False ,
33
- use_trailing_solidus = True ,
34
- space_before_trailing_solidus = False ,
35
- quote_attr_values = "always" ,
36
- quote_char = "'" ,
37
- alphabetical_attributes = True )
30
+ with pytest .deprecated_call ():
31
+ serialized = serialize (parsed ,
32
+ sanitize = True ,
33
+ omit_optional_tags = False ,
34
+ use_trailing_solidus = True ,
35
+ space_before_trailing_solidus = False ,
36
+ quote_attr_values = "always" ,
37
+ quote_char = "'" ,
38
+ alphabetical_attributes = True )
38
39
errorMsg = "\n " .join (["\n \n Input:" , input ,
39
40
"\n Expected:" , expected ,
40
41
"\n Received:" , serialized ])
Original file line number Diff line number Diff line change 8
8
9
9
def sanitize_html (stream ):
10
10
parsed = parseFragment (stream )
11
- serialized = serialize (parsed ,
12
- sanitize = True ,
13
- omit_optional_tags = False ,
14
- use_trailing_solidus = True ,
15
- space_before_trailing_solidus = False ,
16
- quote_attr_values = "always" ,
17
- quote_char = '"' ,
18
- alphabetical_attributes = True )
11
+ with pytest .deprecated_call ():
12
+ serialized = serialize (parsed ,
13
+ sanitize = True ,
14
+ omit_optional_tags = False ,
15
+ use_trailing_solidus = True ,
16
+ space_before_trailing_solidus = False ,
17
+ quote_attr_values = "always" ,
18
+ quote_char = '"' ,
19
+ alphabetical_attributes = True )
19
20
return serialized
20
21
21
22
You can’t perform that action at this time.
0 commit comments