Skip to content

Commit ea55f1c

Browse files
committed
html.parser.HTMLParser.handle_entityref and .handle_charref are no longer used.
https://docs.python.org/3/library/html.parser.html#html.parser.HTMLParser If convert_charrefs is True (the default), all character references (except the ones in script/style elements) are automatically converted to the corresponding Unicode characters. Changed in version 3.5: The default value for argument convert_charrefs is now True.
1 parent f7047de commit ea55f1c

File tree

1 file changed

+0
-21
lines changed

1 file changed

+0
-21
lines changed

metabot/util/html.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -89,27 +89,6 @@ def __append(self, data):
8989
def handle_data(self, data):
9090
self.__append(escape(data))
9191

92-
def handle_entityref(self, name): # pragma: no cover
93-
if name in ('lt', 'gt', 'amp', 'quot'):
94-
self.__append(f'&{name};')
95-
else:
96-
codepoint = html.entities.name2codepoint.get(name)
97-
if codepoint:
98-
self.__append(chr(codepoint))
99-
else:
100-
self.__append(f'&{name};')
101-
102-
def handle_charref(self, name): # pragma: no cover
103-
name = name.lower()
104-
try:
105-
if name.startswith('x'):
106-
codepoint = int(name[1:], 16)
107-
else:
108-
codepoint = int(name)
109-
self.__append(escape(chr(codepoint)))
110-
except (OverflowError, ValueError):
111-
self.__append(f'&#{name};')
112-
11392
def error(self, message): # pragma: no cover pylint: disable=missing-function-docstring
11493
# Remove when support for Python below 3.10 is dropped.
11594
logging.error('HTML sanitizer error: %s', message)

0 commit comments

Comments
 (0)