From 20026e58aad5ab45dc1dd60a047cef7135c2ac80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Borgstr=C3=B6m?= Date: Mon, 13 Apr 2015 22:44:14 +0200 Subject: [PATCH] Fix incorrect behaviour with two character directory names. Independetely found and fixed by both Thomas Waldemann and Cam Hutchison. Closes #265 and #268. --- CHANGES | 1 + attic/helpers.py | 2 +- attic/testsuite/helpers.py | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 4a92bff90..1b7b3788b 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,7 @@ Version 0.15 ------------ (feature release, released on X) +- Fix incorrect behavior with two character directory names (#265, #268) - Require approval before accessing relocated/moved repository (#271) - Require approval before accessing previously unknown unencrypted repositories (#271) - Fix issue with hash index files larger than 2GB. diff --git a/attic/helpers.py b/attic/helpers.py index 6f1be7650..646ba2571 100644 --- a/attic/helpers.py +++ b/attic/helpers.py @@ -513,7 +513,7 @@ def remove_surrogates(s, errors='replace'): return s.encode('utf-8', errors).decode('utf-8') -_safe_re = re.compile('^((..)?/+)+') +_safe_re = re.compile(r'^((\.\.)?/+)+') def make_path_safe(path): diff --git a/attic/testsuite/helpers.py b/attic/testsuite/helpers.py index e84e4dc29..e8c9ee402 100644 --- a/attic/testsuite/helpers.py +++ b/attic/testsuite/helpers.py @@ -109,12 +109,13 @@ class MakePathSafeTestCase(AtticTestCase): def test(self): self.assert_equal(make_path_safe('/foo/bar'), 'foo/bar') self.assert_equal(make_path_safe('/foo/bar'), 'foo/bar') + self.assert_equal(make_path_safe('/f/bar'), 'f/bar') + self.assert_equal(make_path_safe('fo/bar'), 'fo/bar') self.assert_equal(make_path_safe('../foo/bar'), 'foo/bar') self.assert_equal(make_path_safe('../../foo/bar'), 'foo/bar') self.assert_equal(make_path_safe('/'), '.') self.assert_equal(make_path_safe('/'), '.') - class UpgradableLockTestCase(AtticTestCase): def test(self):