mirror of https://github.com/borgbackup/borg.git
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.
This commit is contained in:
parent
63ed5d9949
commit
1f14d1de19
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue