Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use defusedxml to parse potentially untrusted XML #708

Merged
merged 1 commit into from
Nov 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions nbconvert/filters/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
from urllib.parse import quote # Py 3
except ImportError:
from urllib2 import quote # Py 2
from xml.etree import ElementTree

# defusedxml does safe(r) parsing of untrusted XML data
from defusedxml import cElementTree as ElementTree
from xml.etree.cElementTree import Element

from ipython_genutils import py3compat

Expand Down Expand Up @@ -98,7 +101,7 @@ def add_anchor(html, anchor_link_text=u'¶'):
return html
link = _convert_header_id(html2text(h))
h.set('id', link)
a = ElementTree.Element("a", {"class" : "anchor-link", "href" : "#" + link})
a = Element("a", {"class" : "anchor-link", "href" : "#" + link})
a.text = anchor_link_text
h.append(a)

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ def run(self):
'bleach',
'pandocfilters>=1.4.1',
'testpath',
'defusedxml',
]

extra_requirements = {
Expand Down