[PATCH] hgweb: show 404 on missing template in current style (issue3809)

Kevin Bullock kbullock+mercurial at ringworld.org
Tue Feb 5 11:43:04 CST 2013


# HG changeset patch
# User Kevin Bullock <kbullock at ringworld.org>
# Date 1360084904 21600
# Branch stable
# Node ID be8cfc33342e8277b7569f3b1f4f512ca798271a
# Parent  5d02f1d86c2e172d82eba98bc3248f3101c91bc4
hgweb: show 404 on missing template in current style (issue3809)

diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py
+++ b/mercurial/hgweb/hgweb_mod.py
@@ -219,7 +219,11 @@ class hgweb(object):
             tmpl = self.templater(req)
             ctype = tmpl('mimetype', encoding=encoding.encoding)
             ctype = templater.stringify(ctype)
+        except error.Abort, err:
+            req.respond(HTTP_NOT_FOUND, ctype)
+            return tmpl('error', error=str(err))
 
+        try:
             # check read permissions non-static content
             if cmd != 'static':
                 self.check_perm(req, None)
diff --git a/tests/test-hgweb-commands.t b/tests/test-hgweb-commands.t
--- a/tests/test-hgweb-commands.t
+++ b/tests/test-hgweb-commands.t
@@ -1362,10 +1362,8 @@ Test paging
 
   $ cat errors.log
 
-bookmarks view doesn't choke on bookmarks on secret changesets (issue3774)
+missing template results in 404, not traceback
 
-  $ hg phase -fs 4
-  $ hg bookmark -r4 secret
   $ cat > hgweb.cgi <<HGWEB
   > from mercurial import demandimport; demandimport.enable()
   > from mercurial.hgweb import hgweb
@@ -1374,6 +1372,19 @@ bookmarks view doesn't choke on bookmark
   > wsgicgi.launch(app)
   > HGWEB
   $ . "$TESTDIR/cgienv"
+  $ PATH_INFO=/summary; export PATH_INFO
+  $ QUERY_STRING='style=raw'; export QUERY_STRING
+  $ python hgweb.cgi | grep -v ETag:
+  Status: 404 Not Found\r (esc)
+  Content-Type: text/plain; charset=ascii\r (esc)
+  \r (esc)
+  
+  error: "summary" not in template map
+
+bookmarks view doesn't choke on bookmarks on secret changesets (issue3774)
+
+  $ hg phase -fs 4
+  $ hg bookmark -r4 secret
   $ PATH_INFO=/bookmarks; export PATH_INFO
   $ QUERY_STRING='style=raw'
   $ python hgweb.cgi | grep -v ETag:


More information about the Mercurial-devel mailing list