diff mercurial/hgweb/hgweb_mod.py @ 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 8dcd3203a261
children 84bd3fd63afc 71f51cc71652
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