From 1f14d1de1953585221e1dd989bc366d376d0cccb Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 19 Oct 2015 00:01:19 +0200 Subject: [PATCH] acls (linux): use surrogatescape error handling for acl_append_numeric_ids and acl_numeric_ids surrogatescape will decode/encode invalid utf-8 sequences (if we do not get utf-8) in a round-tripping way. --- borg/platform_linux.pyx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/borg/platform_linux.pyx b/borg/platform_linux.pyx index f825aa2a7..58cb88816 100644 --- a/borg/platform_linux.pyx +++ b/borg/platform_linux.pyx @@ -46,7 +46,7 @@ cdef acl_append_numeric_ids(acl): """Extend the "POSIX 1003.1e draft standard 17" format with an additional uid/gid field """ entries = [] - for entry in _comment_re.sub('', acl.decode('ascii')).split('\n'): + for entry in _comment_re.sub('', acl.decode('utf-8', 'surrogateescape')).split('\n'): if entry: type, name, permission = entry.split(':') if name and type == 'user': @@ -55,14 +55,14 @@ cdef acl_append_numeric_ids(acl): entries.append(':'.join([type, name, permission, str(group2gid(name, name))])) else: entries.append(entry) - return ('\n'.join(entries)).encode('ascii') + return '\n'.join(entries).encode('utf-8', 'surrogateescape') cdef acl_numeric_ids(acl): """Replace the "POSIX 1003.1e draft standard 17" user/group field with uid/gid """ entries = [] - for entry in _comment_re.sub('', acl.decode('ascii')).split('\n'): + for entry in _comment_re.sub('', acl.decode('utf-8', 'surrogateescape')).split('\n'): if entry: type, name, permission = entry.split(':') if name and type == 'user': @@ -73,7 +73,7 @@ cdef acl_numeric_ids(acl): entries.append(':'.join([type, gid, permission, gid])) else: entries.append(entry) - return ('\n'.join(entries)).encode('ascii') + return '\n'.join(entries).encode('utf-8', 'surrogateescape') def acl_get(path, item, st, numeric_owner=False):