forked from TrueCloudLab/restic
Correctly encode non utf8 node names
This commit is contained in:
parent
fa94d408f3
commit
45e40eb27a
3 changed files with 50 additions and 1 deletions
26
tree_test.go
26
tree_test.go
|
@ -1,10 +1,13 @@
|
|||
package restic_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/restic/restic"
|
||||
)
|
||||
|
||||
var testFiles = []struct {
|
||||
|
@ -50,3 +53,26 @@ func TestTree(t *testing.T) {
|
|||
}
|
||||
}()
|
||||
}
|
||||
|
||||
var testNodes = []restic.Node{
|
||||
restic.Node{Name: "normal"},
|
||||
restic.Node{Name: "with backslashes \\zzz"},
|
||||
restic.Node{Name: "test utf-8 föbärß"},
|
||||
restic.Node{Name: "test invalid \x00\x01\x02\x03\x04"},
|
||||
restic.Node{Name: "test latin1 \x75\x6d\x6c\xe4\xfc\x74\xf6\x6e\xdf\x6e\x6c\x6c"},
|
||||
}
|
||||
|
||||
func TestNodeMarshal(t *testing.T) {
|
||||
for i, n := range testNodes {
|
||||
data, err := json.Marshal(&n)
|
||||
ok(t, err)
|
||||
|
||||
var node restic.Node
|
||||
err = json.Unmarshal(data, &node)
|
||||
ok(t, err)
|
||||
|
||||
if n.Name != node.Name {
|
||||
t.Fatalf("Node %d: Names are not equal, want: %q got: %q", i, n.Name, node.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue