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

Commit17499b9

Browse files
mobengsnedders
authored andcommitted
Avoid DeprecationWarnings on Python 3.6 (html5lib#318)
Python 3.6 produces warnings on invalid escape sequences instrings, such as "\s", and they will be syntax errors in a futureversion of Python.See <https://docs.python.org/3/reference/lexical_analysis.html#strings>.
1 parentec674a9 commit17499b9

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

‎html5lib/filters/sanitizer.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ def allowed_token(self, token):
782782
# characters, nor why we call unescape. I just know it's always been here.
783783
# Should you be worried by this comment in a sanitizer? Yes. On the other hand, all
784784
# this will do is remove *more* than it otherwise would.
785-
val_unescaped=re.sub("[`\x00-\x20\x7f-\xa0\s]+",'',
785+
val_unescaped=re.sub("[`\x00-\x20\x7f-\xa0\\s]+",'',
786786
unescape(attrs[attr])).lower()
787787
# remove replacement characters from unescaped characters
788788
val_unescaped=val_unescaped.replace("\ufffd","")
@@ -807,7 +807,7 @@ def allowed_token(self, token):
807807
' ',
808808
unescape(attrs[attr]))
809809
if (token["name"]inself.svg_allow_local_hrefand
810-
(namespaces['xlink'],'href')inattrsandre.search('^\s*[^#\s].*',
810+
(namespaces['xlink'],'href')inattrsandre.search(r'^\s*[^#\s].*',
811811
attrs[(namespaces['xlink'],'href')])):
812812
delattrs[(namespaces['xlink'],'href')]
813813
if (None,'style')inattrs:
@@ -837,16 +837,16 @@ def disallowed_token(self, token):
837837

838838
defsanitize_css(self,style):
839839
# disallow urls
840-
style=re.compile('url\s*\(\s*[^\s)]+?\s*\)\s*').sub(' ',style)
840+
style=re.compile(r'url\s*\(\s*[^\s)]+?\s*\)\s*').sub(' ',style)
841841

842842
# gauntlet
843-
ifnotre.match("""^([:,;#%.\sa-zA-Z0-9!]|\w-\w|'[\s\w]+'|"[\s\w]+"|\([\d,\s]+\))*$""",style):
843+
ifnotre.match(r"""^([:,;#%.\sa-zA-Z0-9!]|\w-\w|'[\s\w]+'|"[\s\w]+"|\([\d,\s]+\))*$""",style):
844844
return''
845-
ifnotre.match("^\s*([-\w]+\s*:[^:;]*(;\s*|$))*$",style):
845+
ifnotre.match(r"^\s*([-\w]+\s*:[^:;]*(;\s*|$))*$",style):
846846
return''
847847

848848
clean= []
849-
forprop,valueinre.findall("([-\w]+)\s*:\s*([^:;]*)",style):
849+
forprop,valueinre.findall(r"([-\w]+)\s*:\s*([^:;]*)",style):
850850
ifnotvalue:
851851
continue
852852
ifprop.lower()inself.allowed_css_properties:
@@ -855,7 +855,7 @@ def sanitize_css(self, style):
855855
'padding']:
856856
forkeywordinvalue.split():
857857
ifkeywordnotinself.allowed_css_keywordsand \
858-
notre.match("^(#[0-9a-f]+|rgb\(\d+%?,\d*%?,?\d*%?\)?|\d{0,2}\.?\d{0,2}(cm|em|ex|in|mm|pc|pt|px|%|,|\))?)$",keyword):# noqa
858+
notre.match(r"^(#[0-9a-f]+|rgb\(\d+%?,\d*%?,?\d*%?\)?|\d{0,2}\.?\d{0,2}(cm|em|ex|in|mm|pc|pt|px|%|,|\))?)$",keyword):# noqa
859859
break
860860
else:
861861
clean.append(prop+': '+value+';')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp