# HG changeset patch # User Wagner Bruna # Date 1291128325 7200 # Node ID 86888ae9ce90ae9dfc661169824de0f917d45707 # Parent de4a18cbfc986c2986ebecc4cf488138656e6fbb 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 -r de4a18cbfc98 -r 86888ae9ce90 mercurial/hgweb/hgwebdir_mod.py --- 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) diff -r de4a18cbfc98 -r 86888ae9ce90 tests/test-hgwebdir.t --- 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 diff -r de4a18cbfc98 -r 86888ae9ce90 tests/test-hgwebdirsym.t --- 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