hgwebdir: fix incorrect index generation for invalid paths (issue2023)

8aa8db6deb47 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.
This commit is contained in:
Wagner Bruna 2010-11-30 12:45:25 -02:00
parent ca7126202b
commit e391a0d422
3 changed files with 16 additions and 15 deletions

View File

@ -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)

View File

@ -77,7 +77,7 @@ should give a 404 - repo is not published
404 Not Found
error: repository c not found
error: repository c/file/tip/c not found
[1]
atom-log without basedir

View File

@ -56,19 +56,19 @@ should fail
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