Hi All,

Please find the patch for review.

Thanks,
Abhijeet Kasurde

On 05/10/2016 01:13 PM, Martin Basti wrote:



On 09.05.2016 07:26, Abhijeet Kasurde wrote:
Hi all,

Please review the patch.

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

Thanks,
Abhijeet Kasurde



Hello,

+            self.raise_certificate_operation_error('parse',
+                                                   detail=e.msg)

Please use detail=str(e), e.msg is deprecated

Martin^2


From a0bc1905438546e52705648c718b11ae3cbec9c8 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 | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/ipaserver/plugins/dogtag.py b/ipaserver/plugins/dogtag.py
index 3e5a07de4f653b77027320926efbce384a8eb999..162afbf217e63897cb62e4e292f2cfde62f8a5c9 100644
--- a/ipaserver/plugins/dogtag.py
+++ b/ipaserver/plugins/dogtag.py
@@ -5,8 +5,9 @@
 #   Rob Crittenden <rcritten@@redhat.com>
 #   John Dennis <jden...@redhat.com>
 #   Fraser Tweedale <ftwee...@redhat.com>
+#   Abhijeet Kasurde <akasu...@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 +1381,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('get_parse_result_xml',
+                                                   detail=str(e))
         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