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:
Thomas Waldmann 2015-10-19 00:01:19 +02:00
parent 63ed5d9949
commit 1f14d1de19
1 changed files with 4 additions and 4 deletions

View File

@ -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):