Mercurial > hgrepos > Python > apps > py-cutils
diff cutils/util/walk.py @ 280:f3e0b479928c
treesum: FIX: Also check for that backslashes are nor in u8name or u8path and encode them
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sun, 23 Feb 2025 10:01:09 +0100 |
| parents | f7850ff5cbe0 |
| children | 16507317e834 |
line wrap: on
line diff
--- a/cutils/util/walk.py Sat Feb 22 18:27:10 2025 +0100 +++ b/cutils/util/walk.py Sun Feb 23 10:01:09 2025 +0100 @@ -196,7 +196,7 @@ n = self.uname if n is None: return None - if (u'\n' in n) or (u'\r' in n): + if (u'\n' in n) or (u'\r' in n) or (u'\\' in n): return None return n.encode("utf-8", "strict") @@ -210,7 +210,7 @@ p = self.upath if p is None: return None - if (u'\n' in p) or (u'\r' in p): + if (u'\n' in p) or (u'\r' in p) or (u'\\' in p): return None return p.encode("utf-8", "strict") @@ -235,10 +235,12 @@ s = (WalkDirEntry.surrogate_decode(what) .encode("ascii", "backslashreplace")) else: - s = what.encode("ascii", "backslashreplace") + s = what.encode("ascii", "backslashreplace") else: s = what.encode("utf-8", "backslashreplace") - return s.replace(b'\n', b"\\x0a").replace(b'\r', b"\\x0d") + return (s.replace(b'\\', b"\\x5c") + .replace(b'\n', b"\\x0a") + .replace(b'\r', b"\\x0d")) @property def is_symlink(self):
