[alacarte] MenuEditor: Be resilient to bad XML
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [alacarte] MenuEditor: Be resilient to bad XML
- Date: Fri, 1 Jun 2012 06:09:43 +0000 (UTC)
commit d342bb73bc050a9e7d75c1b34502b49c4cd08ad8
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Fri Jun 1 01:30:55 2012 -0400
MenuEditor: Be resilient to bad XML
https://bugzilla.gnome.org/show_bug.cgi?id=654167
Alacarte/MenuEditor.py | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/Alacarte/MenuEditor.py b/Alacarte/MenuEditor.py
index aeb12b7..3034cba 100644
--- a/Alacarte/MenuEditor.py
+++ b/Alacarte/MenuEditor.py
@@ -16,7 +16,9 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-import os, xml.dom.minidom
+import os
+import xml.dom.minidom
+import xml.parsers.expat
from gi.repository import GMenu, GLib
from Alacarte import util
@@ -32,9 +34,9 @@ class Menu(object):
self.loadDOM()
def loadDOM(self):
- if os.path.isfile(self.path):
+ try:
self.dom = xml.dom.minidom.parse(self.path)
- else:
+ except (IOError, xml.parsers.expat.ExpatError), e:
self.dom = xml.dom.minidom.parseString(util.getUserMenuXml(self.tree))
util.removeWhitespaceNodes(self.dom)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]