rakyll / statik

Embed files into a Go executable
Apache License 2.0
3.76k stars 224 forks source link

Can not handle the path containing dot #72

Closed shumon84 closed 5 years ago

shumon84 commented 5 years ago

(*StatikFS).Open() can not handle the path containing dot.

See below

$ statik -src foo/
$ tree -F
.
├── foo/
│   ├── bar/
│   └── foo.txt
├── main.go
└── statik/
    └── statik.go

3 directories, 3 files
$ cat main.go
// main.go
package main

import (
    _ "./statik"
    "fmt"
    "github.com/rakyll/statik/fs"
    "os"
)

func main() {
    statikFS, _ := fs.New()
    path := "/./bar/../foo.txt"
    _, err1 := statikFS.Open(path)   // os.ErrNotExists occurred
    _, err2 := os.Open("foo" + path) // no errors occur
    fmt.Printf("err1 = %#v\n", err1)
    fmt.Printf("err2 = %#v\n", err2)
}
$ go run main.go
err1 = &errors.errorString{s:"file does not exist"}
err2 = <nil> 

Is this behavior expected? or a bug?