[issue996] hgweb: Problem in hgweb_mod.py's exception handling
Peter Arrenbrecht
mercurial-bugs at selenic.com
Tue Feb 19 11:20:18 CST 2008
New submission from Peter Arrenbrecht <peter.arrenbrecht at gmail.com>:
In hgweb_mod.py, the exception handlers in the following block access tmpl and
ctype, which are only assigned when the request is not a protocol request. I
know too little to fix this myself (what ctype to use for protocol, for
instance), so if someone could give a hint or do a proper fix?
try:
cmd = req.form.get('cmd', [''])[0]
if cmd in protocol.__all__:
method = getattr(protocol, cmd)
method(self, req)
else:
tmpl = self.templater(req)
ctype = tmpl('mimetype', encoding=self.encoding)
ctype = templater.stringify(ctype)
if cmd == '':
req.form['cmd'] = [tmpl.cache['default']]
cmd = req.form['cmd'][0]
if cmd not in webcommands.__all__:
msg = 'No such method: %s' % cmd
raise ErrorResponse(HTTP_BAD_REQUEST, msg)
elif cmd == 'file' and 'raw' in req.form.get('style', []):
self.ctype = ctype
content = webcommands.rawfile(self, req, tmpl)
else:
content = getattr(webcommands, cmd)(self, req, tmpl)
req.respond(HTTP_OK, ctype)
req.write(content)
del tmpl
except revlog.LookupError, err:
req.respond(HTTP_NOT_FOUND, ctype)
req.write(tmpl('error', error='revision not found: %s' % err.name))
except (hg.RepoError, revlog.RevlogError), inst:
req.respond(HTTP_SERVER_ERROR, ctype)
req.write(tmpl('error', error=str(inst)))
except ErrorResponse, inst:
req.respond(inst.code, ctype)
req.write(tmpl('error', error=inst.message))
----------
messages: 5333
nosy: parren
priority: bug
status: unread
title: hgweb: Problem in hgweb_mod.py's exception handling
____________________________________________________
Mercurial issue tracker <mercurial-bugs at selenic.com>
<http://www.selenic.com/mercurial/bts/issue996>
____________________________________________________
More information about the Mercurial-devel
mailing list