diff cutils/util/walk.py @ 371:29a301ff2501

treesum: FIX: also check for TABs when trying to encode strictly
author Franz Glasner <fzglas.hg@dom66.de>
date Sat, 12 Apr 2025 09:05:48 +0200
parents 04d7945ff4ae
children bfe1160fbfd3
line wrap: on
line diff
--- a/cutils/util/walk.py	Fri Apr 11 17:36:14 2025 +0200
+++ b/cutils/util/walk.py	Sat Apr 12 09:05:48 2025 +0200
@@ -153,7 +153,7 @@
     def fsname(self):
         """The name as bytes for the filesystem.
 
-        Also do not allow CR of LF in the name.
+        Also do not allow TAB, CR or LF in the name.
 
         :rtype: bytes or None
 
@@ -167,7 +167,7 @@
                 return None
         else:
             s = os.fsencode(self._name)
-        if (b'\n' in s) or (b'\r' in s) or (b'\\' in s):
+        if (b'\n' in s) or (b'\r' in s) or (b'\t' in s) or (b'\\' in s):
             return None
         return s
 
@@ -175,7 +175,7 @@
     def fspath(self):
         """Always bytes.
 
-        Also do not allow CR of LF in the path.
+        Also do not allow TAB, CR or LF in the path.
 
         :rtype: bytes or None
 
@@ -189,7 +189,7 @@
                 return None
         else:
             p = os.fsencode(self._path)
-        if (b'\n' in p) or (b'\r' in p) or (b'\\' in p):
+        if (b'\n' in p) or (b'\r' in p) or (b'\t' in p) or (b'\\' in p):
             return None
         return p
 
@@ -288,13 +288,13 @@
     def u8name(self):
         """`.uname` as UTF-8 or `None` (as strict as `uname`).
 
-        Also do not allow CR of LF in the name.
+        Also do not allow TAB, CR or LF in the name.
 
         """
         n = self.uname
         if n is None:
             return None
-        if (u'\n' in n) or (u'\r' in n) or (u'\\' in n):
+        if (u'\n' in n) or (u'\r' in n) or (u'\t' in n) or (u'\\' in n):
             return None
         return n.encode("utf-8", "strict")
 
@@ -302,13 +302,13 @@
     def u8path(self):
         """`.upath` as UTF-8 or `None` (as strict as `upath`.
 
-        Also do not allow CR or LF in the path.
+        Also do not allow TAB, CR or LF in the path.
 
         """
         p = self.upath
         if p is None:
             return None
-        if (u'\n' in p) or (u'\r' in p) or (u'\\' in p):
+        if (u'\n' in p) or (u'\r' in p) or (u'\t' in p) or (u'\\' in p):
             return None
         return p.encode("utf-8", "strict")