Skip to content

Commit 70fe97b

Browse files
committed
Fix html5lib#188: the sanitizer should sanitize given a bogus data URL.
1 parent 428cafa commit 70fe97b

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

CHANGES.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
Change Log
22
----------
33

4+
0.9999.1/1.0b5.1
5+
~~~~~~~~~~~~~~~~
6+
7+
Released on April 30, 2015
8+
9+
* Fix #188: fix the sanitizer to not throw an exception when sanitizing
10+
bogus data URLs.
11+
12+
413
0.9999/1.0b5
514
~~~~~~~~~~~~
615

html5lib/sanitizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def allowed_token(self, token, token_type):
215215
m = content_type_rgx.match(uri.path)
216216
if not m:
217217
del attrs[attr]
218-
if m.group('content_type') not in self.allowed_content_types:
218+
elif m.group('content_type') not in self.allowed_content_types:
219219
del attrs[attr]
220220

221221
for attr in self.svg_attr_val_allows_ref:

html5lib/tests/test_sanitizer.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,16 @@ def test_sanitizer():
104104
"""<img src="%s:%s">foo</a>""" % (protocol, rest_of_uri),
105105
toxml)
106106

107+
yield (runSanitizerTest, "test_invalid_data_uri",
108+
"<audio controls=\"\"></audio>",
109+
"<audio controls=\"\" src=\"data:foobar\"></audio>",
110+
toxml)
111+
112+
yield (runSanitizerTest, "test_data_uri_disallowed_type",
113+
"<audio controls=\"\"></audio>",
114+
"<audio controls=\"\" src=\"data:text/html,<html>\"></audio>",
115+
toxml)
116+
107117
for protocol in sanitizer.HTMLSanitizer.allowed_protocols:
108118
rest_of_uri = '//sub.domain.tld/path/object.ext'
109119
if protocol == 'data':

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy