[diffoscope] 01/01: comparators.xml: add support for defusedxml library if available

Juliana Oliveira R jwnx-guest at moszumanska.debian.org
Sun Jul 30 23:22:46 CEST 2017


This is an automated email from the git hooks/post-receive script.

jwnx-guest pushed a commit to branch master
in repository diffoscope.

commit c390ebc9255b9423af5069fe4f56cd632cabf902
Author: Juliana Oliveira Rodrigues <juliana.orod at gmail.com>
Date:   Sun Jul 30 18:13:32 2017 -0300

    comparators.xml: add support for defusedxml library if available
---
 diffoscope/comparators/xml.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/diffoscope/comparators/xml.py b/diffoscope/comparators/xml.py
index 528dddd..f9c8496 100644
--- a/diffoscope/comparators/xml.py
+++ b/diffoscope/comparators/xml.py
@@ -17,14 +17,16 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <https://www.gnu.org/licenses/>.
 
-from xml.dom import minidom
-from xml.parsers.expat import ExpatError
 
+from xml.parsers.expat import ExpatError
 from diffoscope.difference import Difference
 from diffoscope.comparators.utils.file import File
-
 from .missing_file import MissingFile
 
+try:
+  from defusedxml import minidom
+except ImportError:
+  from xml.dom import minidom
 
 def _format(node):
     """
@@ -37,10 +39,10 @@ def _format(node):
         void
     """
     for n in node.childNodes:
-        if n.nodeType == minidom.Node.TEXT_NODE:
+        if n.nodeType == n.TEXT_NODE:
             if n.nodeValue:
                 n.nodeValue = n.nodeValue.strip()
-        elif n.nodeType == minidom.Node.ELEMENT_NODE:
+        elif n.nodeType == n.ELEMENT_NODE:
             _format(n)
 
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list