Mercurial > public > mercurial-scm > hg
diff mercurial/hgweb/webcommands.py @ 7029:b84d27386285
hgweb: Respond with HTTP 403 for disabled archive types instead of 404
This makes it easier for clients/users to distinct between supported
but disabled and unsupported archive types.
author | Rocco Rutte <pdmef@gmx.net> |
---|---|
date | Fri, 05 Sep 2008 17:28:37 +0200 |
parents | 029a54423a96 |
children | 20a5dd5d6dd9 |
line wrap: on
line diff
--- a/mercurial/hgweb/webcommands.py Fri Sep 12 13:28:05 2008 +0200 +++ b/mercurial/hgweb/webcommands.py Fri Sep 05 17:28:37 2008 +0200 @@ -12,7 +12,7 @@ from mercurial.util import binary, datestr from mercurial.repo import RepoError from common import paritygen, staticfile, get_contact, ErrorResponse -from common import HTTP_OK, HTTP_NOT_FOUND +from common import HTTP_OK, HTTP_FORBIDDEN, HTTP_NOT_FOUND from mercurial import graphmod, util # __all__ is populated with the allowed commands. Be sure to add to it if @@ -535,11 +535,15 @@ allowed = web.configlist("web", "allow_archive") key = req.form['node'][0] - if not (type_ in web.archives and (type_ in allowed or - web.configbool("web", "allow" + type_, False))): + if type_ not in web.archives: msg = 'Unsupported archive type: %s' % type_ raise ErrorResponse(HTTP_NOT_FOUND, msg) + if not ((type_ in allowed or + web.configbool("web", "allow" + type_, False))): + msg = 'Archive type not allowed: %s' % type_ + raise ErrorResponse(HTTP_FORBIDDEN, msg) + reponame = re.sub(r"\W+", "-", os.path.basename(web.reponame)) cnode = web.repo.lookup(key) arch_version = key