mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-09 23:00:58 +00:00
Trim string slices upon loading config (fixes #1750)
This commit is contained in:
parent
824fa8f17a
commit
dae1d36a23
@ -578,7 +578,7 @@ func fillNilSlices(data interface{}) error {
|
|||||||
func uniqueStrings(ss []string) []string {
|
func uniqueStrings(ss []string) []string {
|
||||||
var m = make(map[string]bool, len(ss))
|
var m = make(map[string]bool, len(ss))
|
||||||
for _, s := range ss {
|
for _, s := range ss {
|
||||||
m[s] = true
|
m[strings.Trim(s, " ")] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
var us = make([]string, 0, len(m))
|
var us = make([]string, 0, len(m))
|
||||||
|
@ -317,6 +317,29 @@ func TestIssue1262(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIssue1750(t *testing.T) {
|
||||||
|
cfg, err := Load("testdata/issue-1750.xml", device4)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if cfg.Options().ListenAddress[0] != ":23000" {
|
||||||
|
t.Errorf("%q != %q", cfg.Options().ListenAddress[0], ":23000")
|
||||||
|
}
|
||||||
|
|
||||||
|
if cfg.Options().ListenAddress[1] != ":23001" {
|
||||||
|
t.Errorf("%q != %q", cfg.Options().ListenAddress[1], ":23001")
|
||||||
|
}
|
||||||
|
|
||||||
|
if cfg.Options().GlobalAnnServers[0] != "udp4://syncthing.nym.se:22026" {
|
||||||
|
t.Errorf("%q != %q", cfg.Options().GlobalAnnServers[0], "udp4://syncthing.nym.se:22026")
|
||||||
|
}
|
||||||
|
|
||||||
|
if cfg.Options().GlobalAnnServers[1] != "udp4://syncthing.nym.se:22027" {
|
||||||
|
t.Errorf("%q != %q", cfg.Options().GlobalAnnServers[1], "udp4://syncthing.nym.se:22027")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestWindowsPaths(t *testing.T) {
|
func TestWindowsPaths(t *testing.T) {
|
||||||
if runtime.GOOS != "windows" {
|
if runtime.GOOS != "windows" {
|
||||||
t.Skip("Not useful on non-Windows")
|
t.Skip("Not useful on non-Windows")
|
||||||
|
8
internal/config/testdata/issue-1750.xml
vendored
Normal file
8
internal/config/testdata/issue-1750.xml
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<configuration version="9">
|
||||||
|
<options>
|
||||||
|
<listenAddress> :23000</listenAddress>
|
||||||
|
<listenAddress> :23001 </listenAddress>
|
||||||
|
<globalAnnounceServer> udp4://syncthing.nym.se:22026</globalAnnounceServer>
|
||||||
|
<globalAnnounceServer> udp4://syncthing.nym.se:22027 </globalAnnounceServer>
|
||||||
|
</options>
|
||||||
|
</configuration>
|
Loading…
Reference in New Issue
Block a user