[PATCH STABLE] hgwebdir: fix incorrect index generation for invalid paths (issue2023)

Wagner Bruna wagner.bruna+mercurial at gmail.com
Fri Nov 26 08:50:48 CST 2010


# HG changeset patch
# User Wagner Bruna <wbruna at softwareexpress.com.br>
# Date 1290783015 7200
# Branch stable
# Node ID 9b3f2e89aa214abf2a97c7fbe6d20e0463c80223
# Parent  f08df4d38442bf641859f3de860ce0e5b6ba7763
hgwebdir: fix incorrect index generation for invalid paths (issue2023)

edd07be943dd moved the subdirectory match inside the repository match
loop. A virtual path existing/path/invalid/path would then match
existing/path, and generate a wrong index page.

diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py
--- a/mercurial/hgweb/hgwebdir_mod.py
+++ b/mercurial/hgweb/hgwebdir_mod.py
@@ -153,10 +153,11 @@ class hgwebdir(object):
                 # nested indexes and hgwebs
 
                 repos = dict(self.repos)
-                while virtual:
-                    real = repos.get(virtual)
+                virtualrepo = virtual
+                while virtualrepo:
+                    real = repos.get(virtualrepo)
                     if real:
-                        req.env['REPO_NAME'] = virtual
+                        req.env['REPO_NAME'] = virtualrepo
                         try:
                             repo = hg.repository(self.ui, real)
                             return hgweb(repo).run_wsgi(req)
@@ -166,16 +167,16 @@ class hgwebdir(object):
                         except error.RepoError, inst:
                             raise ErrorResponse(HTTP_SERVER_ERROR, str(inst))
 
-                    # browse subdirectories
-                    subdir = virtual + '/'
-                    if [r for r in repos if r.startswith(subdir)]:
-                        req.respond(HTTP_OK, ctype)
-                        return self.makeindex(req, tmpl, subdir)
-
-                    up = virtual.rfind('/')
+                    up = virtualrepo.rfind('/')
                     if up < 0:
                         break
-                    virtual = virtual[:up]
+                    virtualrepo = virtualrepo[:up]
+
+                # browse subdirectories
+                subdir = virtual + '/'
+                if [r for r in repos if r.startswith(subdir)]:
+                    req.respond(HTTP_OK, ctype)
+                    return self.makeindex(req, tmpl, subdir)
 
                 # prefixes not found
                 req.respond(HTTP_NOT_FOUND, ctype)


More information about the Mercurial-devel mailing list