2
0
Эх сурвалжийг харах

Fix incorrect behaviour with two character directory names.

Independetely found and fixed by both Thomas Waldemann and
Cam Hutchison. Closes #265 and #268.
Jonas Borgström 10 жил өмнө
parent
commit
20026e58aa

+ 1 - 0
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.

+ 1 - 1
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):

+ 2 - 1
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):