😬
This commit is contained in:
@@ -12,6 +12,8 @@ import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"iter"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"testing"
|
||||
@@ -20,6 +22,7 @@ import (
|
||||
"github.com/syncthing/syncthing/internal/db"
|
||||
"github.com/syncthing/syncthing/internal/itererr"
|
||||
"github.com/syncthing/syncthing/internal/timeutil"
|
||||
"github.com/syncthing/syncthing/lib/build"
|
||||
"github.com/syncthing/syncthing/lib/config"
|
||||
"github.com/syncthing/syncthing/lib/protocol"
|
||||
)
|
||||
@@ -1157,6 +1160,47 @@ func TestStrangeDeletedGlobalBug(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenSpecialName(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
|
||||
// Create a "base" dir that is in the way if the path becomes
|
||||
// incorrectly truncated in the next steps.
|
||||
base := path.Join(dir, "test")
|
||||
if err := os.Mkdir(base, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Should be able to open a path with a hash sign in it.
|
||||
p1 := base + "#foo"
|
||||
db, err := Open(p1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(db.path)
|
||||
db.Close()
|
||||
|
||||
if !build.IsWindows {
|
||||
// Should be able to open a path with something that looks like
|
||||
// query params.
|
||||
p2 := base + "?foo=bar"
|
||||
db, err = Open(p2)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(db.path)
|
||||
db.Close()
|
||||
}
|
||||
|
||||
// Better not a have problem with a single ampersand either.
|
||||
p2 := base + "&foo"
|
||||
db, err = Open(p2)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(db.path)
|
||||
db.Close()
|
||||
}
|
||||
|
||||
func mustCollect[T any](t *testing.T) func(it iter.Seq[T], errFn func() error) []T {
|
||||
t.Helper()
|
||||
return func(it iter.Seq[T], errFn func() error) []T {
|
||||
|
||||
Reference in New Issue
Block a user