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:
parent
94d7041e8e
commit
f9adee80f4
1 changed files with 10 additions and 2 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue