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 ...@@ -45,6 +45,7 @@ from cStringIO import StringIO
from urllib import pathname2url, urlopen, splittype, urlretrieve from urllib import pathname2url, urlopen, splittype, urlretrieve
import re import re
from xml.dom.minidom import parse from xml.dom.minidom import parse
from xml.parsers.expat import ExpatError
import struct import struct
import cPickle import cPickle
import posixpath import posixpath
...@@ -525,8 +526,18 @@ class TemplateTool (BaseTool): ...@@ -525,8 +526,18 @@ class TemplateTool (BaseTool):
url = '/'.join([repository, 'bt5list']) url = '/'.join([repository, 'bt5list'])
f = urlopen(url) f = urlopen(url)
property_dict_list = [] property_dict_list = []
try:
try: try:
doc = parse(f) 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: try:
root = doc.documentElement root = doc.documentElement
for template in root.getElementsByTagName("template"): 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