1
0
Fork 0
mirror of https://github.com/vbatts/go-mtree.git synced 2024-11-25 01:25:39 +00:00

keywords: encode xattr.* keywords with Vis

This allows for xattr keywords to include spaces and other such options
(which is perfectly valid according to the definition of Lsetxattr --
any character except '\x00' is fair game).

Signed-off-by: Aleksa Sarai <asarai@suse.de>
This commit is contained in:
Aleksa Sarai 2016-12-18 02:57:45 +11:00
parent 94d7041e8e
commit f9adee80f4
No known key found for this signature in database
GPG key ID: 9E18AA267DDB8DB4

View file

@ -62,7 +62,11 @@ var (
} }
klist := []KeyVal{} klist := []KeyVal{}
for k, v := range hdr.Xattrs { for k, v := range hdr.Xattrs {
klist = append(klist, KeyVal(fmt.Sprintf("xattr.%s=%s", k, base64.StdEncoding.EncodeToString([]byte(v))))) encKey, err := Vis(k, DefaultVisFlags)
if err != nil {
return emptyKV, err
}
klist = append(klist, KeyVal(fmt.Sprintf("xattr.%s=%s", encKey, base64.StdEncoding.EncodeToString([]byte(v)))))
} }
return KeyVal(strings.Join(KeyValToString(klist), " ")), nil return KeyVal(strings.Join(KeyValToString(klist), " ")), nil
} }
@ -80,7 +84,11 @@ var (
if err != nil { if err != nil {
return emptyKV, err return emptyKV, err
} }
klist[i] = KeyVal(fmt.Sprintf("xattr.%s=%s", xlist[i], base64.StdEncoding.EncodeToString(data))) encKey, err := Vis(xlist[i], DefaultVisFlags)
if err != nil {
return emptyKV, err
}
klist[i] = KeyVal(fmt.Sprintf("xattr.%s=%s", encKey, base64.StdEncoding.EncodeToString(data)))
} }
return KeyVal(strings.Join(KeyValToString(klist), " ")), nil return KeyVal(strings.Join(KeyValToString(klist), " ")), nil
} }