acls (posix platforms): use surrogatescape error handling for posix_acl_use_stored_uid_gid

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-18 23:43:24 +02:00
parent b2cffe00fe
commit 63ed5d9949
1 changed files with 2 additions and 2 deletions

View File

@ -516,14 +516,14 @@ def posix_acl_use_stored_uid_gid(acl):
"""Replace the user/group field with the stored uid/gid
"""
entries = []
for entry in acl.decode('ascii').split('\n'):
for entry in acl.decode('utf-8', 'surrogateescape').split('\n'):
if entry:
fields = entry.split(':')
if len(fields) == 4:
entries.append(':'.join([fields[0], fields[3], fields[2]]))
else:
entries.append(entry)
return ('\n'.join(entries)).encode('ascii')
return '\n'.join(entries).encode('utf-8', 'surrogateescape')
class Location: