diff options
author | Zac Medico <zmedico@gentoo.org> | 2012-12-11 03:09:27 -0800 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2012-12-11 03:09:27 -0800 |
commit | 4cab89345f8c236cdc91f596b5168763f6051ab2 (patch) | |
tree | 36f35efc3b169b0ce929da0a221e145d7050a95c | |
parent | f0e2fa9404570891e564d9c6f65f0d577ba53d35 (diff) | |
download | portage-4cab89345f8c236cdc91f596b5168763f6051ab2.tar.gz portage-4cab89345f8c236cdc91f596b5168763f6051ab2.tar.bz2 portage-4cab89345f8c236cdc91f596b5168763f6051ab2.zip |
xattr-helper.py: fix backslash quoting
-rwxr-xr-x | bin/xattr-helper.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/bin/xattr-helper.py b/bin/xattr-helper.py index d40217c9a..b832f5ea7 100755 --- a/bin/xattr-helper.py +++ b/bin/xattr-helper.py @@ -94,11 +94,14 @@ def dump_xattrs(file_in, file_out): attrs = xattr.list(pathname) if not attrs: continue - file_out.write(b'# file: ' + quote(pathname, b'\n\r') + b'\n') + + # NOTE: Always quote backslashes, in order to ensure that they are + # not interpreted as quotes when they are processed by unquote. + file_out.write(b'# file: ' + quote(pathname, b'\n\r\\\\') + b'\n') for attr in attrs: attr = unicode_encode(attr) - file_out.write(quote(attr, b'=\n\r') + b'="' + - quote(xattr.get(pathname, attr), b'\\\0\n\r"') + b'"\n') + file_out.write(quote(attr, b'=\n\r\\\\') + b'="' + + quote(xattr.get(pathname, attr), b'\0\n\r"\\\\') + b'"\n') def restore_xattrs(file_in): |