From ab3ba4a1778e57cd6aaba4feee6f9c534a39b52e Mon Sep 17 00:00:00 2001 From: joshn Date: Sat, 16 May 2009 03:00:57 +0000 Subject: Provide backwards compatibility with non-unicode version of Windows ACL file. git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@1055 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109 --- rdiff-backup/rdiff_backup/win_acls.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rdiff-backup/rdiff_backup/win_acls.py b/rdiff-backup/rdiff_backup/win_acls.py index 603a5fe..91f17d8 100644 --- a/rdiff-backup/rdiff_backup/win_acls.py +++ b/rdiff-backup/rdiff_backup/win_acls.py @@ -28,6 +28,11 @@ except ImportError: OWNER_SECURITY_INFORMATION = 0 DACL_SECURITY_INFORMATION = 0 +def encode(str_): + if type(str_) == unicode: + return str_.encode('utf-8') + return str_ + class ACL: flags = (GROUP_SECURITY_INFORMATION| OWNER_SECURITY_INFORMATION| @@ -181,7 +186,8 @@ class ACL: def __str__(self): return '# file: %s\n%s\n' % \ - (self.get_indexpath(), unicode(self.__acl)) + (C.acl_quote(encode(self.get_indexpath())), + unicode(self.__acl)) def from_string(self, acl_str): lines = acl_str.splitlines() @@ -189,7 +195,7 @@ class ACL: raise metadata.ParsingError("Bad record beginning: " + lines[0][:8]) filename = lines[0][8:] if filename == '.': self.index = () - else: self.index = tuple(filename.split('/')) + else: self.index = tuple(unicode(C.acl_unquote(filename)).split('/')) self.__acl = lines[1] def Record2WACL(record): -- cgit v1.2.1