Skip to content
This repository has been archived by the owner on Jun 25, 2022. It is now read-only.

Commit

Permalink
Improve test cases for file resolution (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
hdm authored and markbates committed Aug 26, 2019
1 parent bcc60f5 commit ba53cc4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions v2/box_test.go
Expand Up @@ -227,27 +227,27 @@ func Test_Box_HasDir(t *testing.T) {
func Test_Box_Traversal_Standard(t *testing.T) {
r := require.New(t)
box := New("Test_Box_Traversal_Standard", "")
_, err := box.FindString("../go.mod")
_, err := box.FindString("../fixtures/hello.txt")
r.Error(err)
}

func Test_Box_Traversal_Standard_Depth2(t *testing.T) {
r := require.New(t)
box := New("Test_Box_Traversal_Standard_Depth2", "")
_, err := box.FindString("../../packr/go.mod")
_, err := box.FindString("../../packr/fixtures/hello.txt")
r.Error(err)
}

func Test_Box_Traversal_Backslash(t *testing.T) {
r := require.New(t)
box := New("Test_Box_Traversal_Backslash", "")
_, err := box.FindString("..\\go.mod")
_, err := box.FindString("..\\fixtures\\hello.txt")
r.Error(err)
}

func Test_Box_Traversal_Backslash_Depth2(t *testing.T) {
r := require.New(t)
box := New("Test_Box_Traversal_Backslash_Depth2", "")
_, err := box.FindString("..\\..packr2\\go.mod")
_, err := box.FindString("..\\..\\packr2\\fixtures\\hello.txt")
r.Error(err)
}
4 changes: 2 additions & 2 deletions v2/file/resolver/disk.go
Expand Up @@ -45,8 +45,8 @@ func (d *Disk) Resolve(box string, name string) (file.File, error) {
return nil, os.ErrNotExist
}

// resolvePathInBase returns a path that is guaranteed to be inside of the base directory or an error
func ResolvePathInBase(base string, path string) (string, error) {
// ResolvePathInBase returns a path that is guaranteed to be inside of the base directory or an error
func ResolvePathInBase(base, path string) (string, error) {
// Determine the absolute file path of the base directory
d, err := filepath.Abs(base)
if err != nil {
Expand Down

0 comments on commit ba53cc4

Please sign in to comment.