Commit b187cc9b authored by Nicolas Dumazet's avatar Nicolas Dumazet

Catch xml.parser.expat.ExpatError when an invalid bt5 repo is passed along


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@29793 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9478426a
......@@ -45,6 +45,7 @@ from cStringIO import StringIO
from urllib import pathname2url, urlopen, splittype, urlretrieve
import re
from xml.dom.minidom import parse
from xml.parsers.expat import ExpatError
import struct
import cPickle
import posixpath
......@@ -525,8 +526,18 @@ class TemplateTool (BaseTool):
url = '/'.join([repository, 'bt5list'])
f = urlopen(url)
property_dict_list = []
try:
try:
doc = parse(f)
except ExpatError:
if REQUEST is not None:
psm = translateString('Invalid repository: ${repo}',
mapping={'repo':repository})
REQUEST.RESPONSE.redirect("%s?portal_status_message=%s"
% (self.absolute_url(), psm))
return
else:
raise RuntimeError, 'Invalid repository: %s' % repository
try:
root = doc.documentElement
for template in root.getElementsByTagName("template"):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment