Skip to content

Commit 0818628

Browse files
martinRenouSylvainCorlay
authored andcommitted
Check input type before escaping
1 parent b206470 commit 0818628

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

nbconvert/exporters/templateexporter.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@
4040
)
4141

4242

43+
def escape_html(s, quote=True):
44+
if not isinstance(s, str):
45+
return s
46+
else:
47+
return html.escape(s)
48+
49+
4350
default_filters = {
4451
"indent": filters.indent,
4552
"markdown2html": filters.markdown2html,
@@ -71,7 +78,7 @@
7178
"convert_pandoc": filters.convert_pandoc,
7279
"json_dumps": json.dumps,
7380
# For removing any HTML
74-
"escape_html": html.escape,
81+
"escape_html": escape_html,
7582
# For sanitizing HTML for any XSS
7683
"clean_html": clean_html,
7784
"strip_trailing_newline": filters.strip_trailing_newline,

0 commit comments

Comments
 (0)