From: Daira Hopwood Date: Thu, 22 Oct 2015 13:28:26 +0000 (+0100) Subject: Fix infinite loop in should_ignore_path for absolute paths. X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/frontends/using.html?a=commitdiff_plain;h=f11ba5d8782679c8ebfac3231881536cbc9e5eea;p=tahoe-lafs%2Ftahoe-lafs.git Fix infinite loop in should_ignore_path for absolute paths. Signed-off-by: Daira Hopwood --- diff --git a/src/allmydata/magicpath.py b/src/allmydata/magicpath.py index ba15ed58..53e669b6 100644 --- a/src/allmydata/magicpath.py +++ b/src/allmydata/magicpath.py @@ -2,7 +2,7 @@ import re import os.path -from allmydata.util.assertutil import precondition +from allmydata.util.assertutil import precondition, _assert def path2magic(path): return re.sub(ur'[/@]', lambda m: {u'/': u'@_', u'@': u'@@'}[m.group(0)], path) @@ -20,8 +20,14 @@ def should_ignore_file(path_u): for suffix in IGNORE_SUFFIXES: if path_u.endswith(suffix): return True + while path_u != u"": + oldpath_u = path_u path_u, tail_u = os.path.split(path_u) if tail_u.startswith(u"."): return True + if path_u == oldpath_u: + return True # the path was absolute + _assert(len(path_u) < len(oldpath_u), path_u=path_u, oldpath_u=oldpath_u) + return False