hgwebdir: fix incorrect index generation for invalid paths (issue2023) stable
authorWagner Bruna <wbruna@softwareexpress.com.br>
Tue, 30 Nov 2010 12:45:25 -0200
branchstable
changeset 13066 86888ae9ce90
parent 13065 de4a18cbfc98
child 13067 9696954415db
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.
mercurial/hgweb/hgwebdir_mod.py
tests/test-hgwebdir.t
tests/test-hgwebdirsym.t
--- a/mercurial/hgweb/hgwebdir_mod.py	Fri Nov 26 18:45:35 2010 +0100
+++ b/mercurial/hgweb/hgwebdir_mod.py	Tue Nov 30 12:45:25 2010 -0200
@@ -153,10 +153,11 @@
                 # 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 @@
                         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)
--- a/tests/test-hgwebdir.t	Fri Nov 26 18:45:35 2010 +0100
+++ b/tests/test-hgwebdir.t	Tue Nov 30 12:45:25 2010 -0200
@@ -77,7 +77,7 @@
   404 Not Found
   
   
-  error: repository c not found
+  error: repository c/file/tip/c not found
   [1]
 
 atom-log without basedir
--- a/tests/test-hgwebdirsym.t	Fri Nov 26 18:45:35 2010 +0100
+++ b/tests/test-hgwebdirsym.t	Tue Nov 30 12:45:25 2010 -0200
@@ -56,19 +56,19 @@
   404 Not Found
   
   
-  error: repository circle not found
+  error: repository circle/al/file/tip/a not found
   [1]
   $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/circle/b/file/tip/a?style=raw'
   404 Not Found
   
   
-  error: repository circle not found
+  error: repository circle/b/file/tip/a not found
   [1]
   $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/circle/c/file/tip/a?style=raw'
   404 Not Found
   
   
-  error: repository circle not found
+  error: repository circle/c/file/tip/a not found
   [1]
 
 collections errors