Hi all,

Please review the patch.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1333755

Thanks,
Abhijeet Kasurde

From 7f3d167ddd80bfe767721c2ace069375205b2b84 Mon Sep 17 00:00:00 2001
From: Abhijeet Kasurde <akasu...@redhat.com>
Date: Mon, 9 May 2016 10:31:24 +0530
Subject: [PATCH] Added exception handling for mal-formatted XML Parsing

In order to handle mal-formatted XML returned from Dogtag, added
exception handling around etree.fromstring function.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1333755

Signed-off-by: Abhijeet Kasurde <akasu...@redhat.com>
---
 ipaserver/plugins/dogtag.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/ipaserver/plugins/dogtag.py b/ipaserver/plugins/dogtag.py
index 3e5a07de4f653b77027320926efbce384a8eb999..95d3473fd244cdb418275291b623ef4f2b955401 100644
--- a/ipaserver/plugins/dogtag.py
+++ b/ipaserver/plugins/dogtag.py
@@ -6,7 +6,7 @@
 #   John Dennis <jden...@redhat.com>
 #   Fraser Tweedale <ftwee...@redhat.com>
 #
-# Copyright (C) 2014, 2015  Red Hat
+# Copyright (C) 2014-2016  Red Hat, Inc.
 # see file 'COPYING' for use and warranty information
 #
 # This program is free software; you can redistribute it and/or modify
@@ -1380,7 +1380,11 @@ class ra(rabase.rabase):
         to get the parsing result as a dict of key/value pairs.
         '''
         parser = etree.XMLParser()
-        doc = etree.fromstring(xml_text, parser)
+        try:
+            doc = etree.fromstring(xml_text, parser)
+        except etree.XMLSyntaxError as e:
+            self.raise_certificate_operation_error('parse',
+                                                   detail=e.msg)
         result = parse_func(doc)
         self.debug("%s() xml_text:\n%s\n"
                    "parse_result:\n%s" % (parse_func.__name__, xml_text, result))
-- 
2.4.11

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to