fix(platform): support Windows storage and native filesystem boundaries
This commit is contained in:
1 parent
3726423338
commit
e239fff253
24 files changed
+355
-51
No files matched your search
@@ -0,0 +1,32 @@
|
||||
package backup
|
||||
|
||||
import (
|
||||
"archive/zip"
|
||||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRejectWindowsArchivePaths(t *testing.T) {
|
||||
for _, name := range []string{"C:escape", "vault/note.md:stream", "vault/CON", "vault/dir./note.md"} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
file := filepath.Join(t.TempDir(), "invalid.zip")
|
||||
f, err := os.Create(file)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
z := zip.NewWriter(f)
|
||||
if _, err := z.Create(name); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := errors.Join(z.Close(), f.Close()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := Extract(context.Background(), file, t.TempDir()); !errors.Is(err, ErrInvalidArchive) {
|
||||
t.Fatalf("unsafe archive path accepted: %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user