From bb7b805e9838225a912041690e6a4cd0654dcbd8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Rekucki?= Date: Mon, 26 Apr 2010 18:54:18 +0200 Subject: [PATCH 1/1] Bug that caused inifinite recursion while searching for non-existant document. --- apps/wiki/urls.py | 3 ++- lib/vstorage.py | 8 ++++++-- redakcja/urls.py | 6 +++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/apps/wiki/urls.py b/apps/wiki/urls.py index c5c08a13..bfc799f5 100644 --- a/apps/wiki/urls.py +++ b/apps/wiki/urls.py @@ -1,11 +1,12 @@ from django.conf.urls.defaults import * -from django.conf import settings urlpatterns = patterns('wiki.views', url(r'^$', 'document_list', name='wiki_doclist'), + url(r'^create/(?P[^/]+)', 'document_create_missing', name='wiki_create_missing'), + url(r'^gallery/(?P[^/]+)$', 'document_gallery', name="wiki_gallery"), url(r'^(?P[^/]+)/history$', diff --git a/lib/vstorage.py b/lib/vstorage.py index 82151da7..b4acaf3a 100644 --- a/lib/vstorage.py +++ b/lib/vstorage.py @@ -328,16 +328,20 @@ class VersionedStorage(object): """Find the last revision in which the file existed.""" repo_file = self._title_to_file(title) changectx = self._changectx() # start with tip + visited = set() + stack = [changectx] + visited.add(changectx) while repo_file not in changectx: if not stack: - return None + raise DocumentNotFound(title) changectx = stack.pop() for parent in changectx.parents(): - if parent != changectx: + if parent not in visited: stack.append(parent) + visited.add(parent) try: fctx = changectx[repo_file] diff --git a/redakcja/urls.py b/redakcja/urls.py index 904ad447..f8538fa8 100644 --- a/redakcja/urls.py +++ b/redakcja/urls.py @@ -16,6 +16,9 @@ urlpatterns = patterns('', url(r'^admin/doc/', include('django.contrib.admindocs.urls')), (r'^admin/', include(admin.site.urls)), + url(r'^$', 'django.views.generic.simple.redirect_to', {'url': '/documents/'}), + url(r'^documents/', include('wiki.urls')), + # Static files (should be served by Apache) url(r'^%s(?P.+)$' % settings.MEDIA_URL[1:], 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}), @@ -23,7 +26,4 @@ urlpatterns = patterns('', {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}), url(r'^%s(?P.+)$' % settings.STATIC_URL[1:], 'django.views.static.serve', {'document_root': settings.STATIC_ROOT, 'show_indexes': True}), - - url(r'^$', 'django.views.generic.simple.redirect_to', {'url': '/documents/'}), - url(r'^documents/', include('wiki.urls')), ) -- 2.20.1