[bug] Glob doesn't match files with names starting with "【"
bnkai opened this issue · comments
First thanks for this wonderful doublestar glob, it makes file matching very easy.
A possible bug we encountered in our usage of doublestar.Glob:
When a file has its name starting with "【" ( Lenticular bracket wikipedia , ulookup ) it doesnt seem to match. Having the "【" in the path or in the filename but not as first character the file matches.
An example to illustrate the issue.
touch "/home/username/test/file.mp4"
touch "/home/username/test/【file.mp4"
touch "/home/username/test/ 【file.mp4"
note: the second file has the filename starting with "【" while the third has an extra space added " 【" ( can be any normal
char instead of space )
Running the below code ( close to our use case)
package main
import (
"fmt"
"github.com/bmatcuk/doublestar"
"path/filepath"
)
func main() {
path := "/home/username/test"
pattern := "**/*.{mp4}"
re, err := doublestar.Glob(filepath.Join(path, pattern))
if err != nil {
fmt.Printf("error %v", err)
}
for _, file := range re {
fmt.Println(file)
}
}
The files printed ( matched ) are the first and the last not the second.
/home/username/test/ 【file.mp4
/home/username/test/file.mp4
Apart from "【" i would suspect more special unicode characters won't match.
Hi @bnkai - I'm really sorry this took so long for me to get to! I intended on taking a look last weekend, but, before I knew it, the weekend was over!
Anyway, thank you for the well-written bug report! I think I've found the issue and just cut a v1.3.1. I've also included a test case for this issue that seems to be passing. Let me know if you have any further trouble!