[ARVADOS] updated: 1.3.0-64-g5139019de

Git user git at public.curoverse.com
Thu Dec 20 14:34:01 EST 2018


Summary of changes:
 sdk/python/arvados/collection.py     |  5 ++---
 sdk/python/tests/test_collections.py | 30 ++++++++++++++++++------------
 2 files changed, 20 insertions(+), 15 deletions(-)

       via  5139019ded0a1c79f50906f5cab9abcc04ecc95b (commit)
      from  41e5e2b86739f759a849dfcac38d442b106f2c46 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 5139019ded0a1c79f50906f5cab9abcc04ecc95b
Author: Lucas Di Pentima <ldipentima at veritasgenetics.com>
Date:   Thu Dec 20 16:32:39 2018 -0300

    14539: Escape backslash & space chars on file/dir names, with tests.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima at veritasgenetics.com>

diff --git a/sdk/python/arvados/collection.py b/sdk/python/arvados/collection.py
index c2517c618..dcdf789ae 100644
--- a/sdk/python/arvados/collection.py
+++ b/sdk/python/arvados/collection.py
@@ -600,9 +600,8 @@ class RichCollectionBase(CollectionBase):
 
         pathcomponents = path.split("/", 1)
         if pathcomponents[0]:
-            # Don't allow naming files/dirs \\056
-            if pathcomponents[0] == "\\056":
-                raise IOError(errno.EINVAL, "Invalid name", pathcomponents[0])
+            # Escape '\' & ' ' chars on path names
+            pathcomponents[0] = pathcomponents[0].replace('\\', '\\134').replace(' ', '\\040')
             item = self._items.get(pathcomponents[0])
             if len(pathcomponents) == 1:
                 if item is None:
diff --git a/sdk/python/tests/test_collections.py b/sdk/python/tests/test_collections.py
index 55dd0838f..aa4938a47 100644
--- a/sdk/python/tests/test_collections.py
+++ b/sdk/python/tests/test_collections.py
@@ -952,22 +952,28 @@ class NewCollectionTestCase(unittest.TestCase, CollectionTestMixin):
         self.assertIs(c.find("./nonexistant.txt"), None)
         self.assertIs(c.find("./nonexistantsubdir/nonexistant.txt"), None)
 
-    def test_remove_in_subdir(self):
-        c = Collection('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt\n./foo 781e5e245d69b566979b86e28d23f2c7+10 0:10:count2.txt\n')
-        c.remove("foo/count2.txt")
-        self.assertEqual(". 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt\n./foo d41d8cd98f00b204e9800998ecf8427e+0 0:0:\\056\n", c.portable_manifest_text())
+    def test_escaped_paths_dont_get_unescaped(self):
+        # Dir & file names are literally '\056' (escaped form: \134056)
+        manifest = './\\134056\\040Test d41d8cd98f00b204e9800998ecf8427e+0 0:0:\\134056\n'
+        c = Collection(manifest)
+        self.assertEqual(c.portable_manifest_text(), manifest)
 
-    def test_create_dot_file(self):
+    def test_make_empty_dir_with_escaped_chars(self):
         c = Collection()
-        with self.assertRaises(IOError):
-            with c.open("./dir/\\056", "wb") as f:
-                f.write("Should not be allowed")
+        c.mkdirs('./Empty\\056Dir')
+        self.assertEqual(c.portable_manifest_text(),
+                         './Empty\\134056Dir d41d8cd98f00b204e9800998ecf8427e+0 0:0:\\056\n')
 
-    def test_create_file_inside_dot_dir(self):
+    def test_make_empty_dir_with_spaces(self):
         c = Collection()
-        with self.assertRaises(IOError):
-            with c.open("./dir/\\056/foo", "wb") as f:
-                f.write("Should not be allowed")
+        c.mkdirs('./Empty Dir With Spaces')
+        self.assertEqual(c.portable_manifest_text(),
+                         './Empty\\040Dir\\040With\\040Spaces d41d8cd98f00b204e9800998ecf8427e+0 0:0:\\056\n')
+
+    def test_remove_in_subdir(self):
+        c = Collection('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt\n./foo 781e5e245d69b566979b86e28d23f2c7+10 0:10:count2.txt\n')
+        c.remove("foo/count2.txt")
+        self.assertEqual(". 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt\n./foo d41d8cd98f00b204e9800998ecf8427e+0 0:0:\\056\n", c.portable_manifest_text())
 
     def test_remove_empty_subdir(self):
         c = Collection('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt\n./foo 781e5e245d69b566979b86e28d23f2c7+10 0:10:count2.txt\n')

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list