Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit29526c5

Browse files
committed
When URLs are invalid IPv6 URLs drop the attr rather than error
1 parent01b1ebb commit29526c5

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

‎html5lib/sanitizer.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,11 @@ def allowed_token(self, token, token_type):
207207
unescape(attrs[attr])).lower()
208208
# remove replacement characters from unescaped characters
209209
val_unescaped=val_unescaped.replace("\ufffd","")
210-
uri=urlparse.urlparse(val_unescaped)
210+
try:
211+
uri=urlparse.urlparse(val_unescaped)
212+
exceptValueError:
213+
uri=None
214+
delattrs[attr]
211215
ifurianduri.scheme:
212216
ifuri.schemenotinself.allowed_protocols:
213217
delattrs[attr]

‎html5lib/tests/test_sanitizer.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ def test_sanitizer():
113113
"<audio controls=\"\" src=\"data:foobar\"></audio>",
114114
toxml)
115115

116+
yield (runSanitizerTest,"test_invalid_ipv6_url",
117+
"<a>",
118+
"<a href=\"h://]\">",
119+
toxml)
120+
116121
yield (runSanitizerTest,"test_data_uri_disallowed_type",
117122
"<audio controls=\"\"></audio>",
118123
"<audio controls=\"\" src=\"data:text/html,<html>\"></audio>",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp