Mercurial > hg-stable
changeset 13445:61a898576888 stable
hgweb: handle invalid requests with both form data and querystring
Invalid requests could give an unhandled ErrorResponse.
Now this ErrorResponse is handled like other ErrorResponses so the client gets
an error message which also is logged on the server.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Mon, 21 Feb 2011 00:57:19 +0100 |
parents | 75f5f312df5f |
children | 1e497df514e2 |
files | mercurial/hgweb/hgweb_mod.py tests/test-http.t |
diffstat | 2 files changed, 21 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hgweb/hgweb_mod.py Mon Feb 21 00:52:26 2011 +0100 +++ b/mercurial/hgweb/hgweb_mod.py Mon Feb 21 00:57:19 2011 +0100 @@ -114,17 +114,17 @@ cmd = req.form.get('cmd', [''])[0] if protocol.iscmd(cmd): - if query: - raise ErrorResponse(HTTP_NOT_FOUND) - if cmd in perms: - try: + try: + if query: + raise ErrorResponse(HTTP_NOT_FOUND) + if cmd in perms: self.check_perm(req, perms[cmd]) - except ErrorResponse, inst: - if cmd == 'unbundle': - req.drain() - req.respond(inst, protocol.HGTYPE) - return '0\n%s\n' % inst.message - return protocol.call(self.repo, req, cmd) + return protocol.call(self.repo, req, cmd) + except ErrorResponse, inst: + if cmd == 'unbundle': + req.drain() + req.respond(inst, protocol.HGTYPE) + return '0\n%s\n' % inst.message # translate user-visible url structure to internal structure
--- a/tests/test-http.t Mon Feb 21 00:52:26 2011 +0100 +++ b/tests/test-http.t Mon Feb 21 00:57:19 2011 +0100 @@ -11,7 +11,7 @@ adding foo.d/bAr.hg.d/BaR adding foo.d/baR.d.hg/bAR adding foo.d/foo - $ hg serve -p $HGPORT -d --pid-file=../hg1.pid + $ hg serve -p $HGPORT -d --pid-file=../hg1.pid -E ../error.log $ hg --config server.uncompressed=False serve -p $HGPORT1 -d --pid-file=../hg2.pid Test server address cannot be reused @@ -85,3 +85,13 @@ changegroup hook: HG_NODE=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_SOURCE=pull HG_URL=http://localhost:$HGPORT1/ (run 'hg update' to get a working copy) $ cd .. + +clone from invalid URL + + $ hg clone http://localhost:$HGPORT/bad + abort: HTTP Error 404: Not Found + [255] + +check error log + + $ cat error.log