Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Glob doesn't match files with names starting with "【" #40

Closed
bnkai opened this issue May 24, 2020 · 2 comments
Closed

[bug] Glob doesn't match files with names starting with "【" #40

bnkai opened this issue May 24, 2020 · 2 comments
Assignees
Labels

Comments

@bnkai
Copy link

bnkai commented May 24, 2020

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.

@bmatcuk bmatcuk self-assigned this May 31, 2020
@bmatcuk bmatcuk added the bug label May 31, 2020
@bmatcuk
Copy link
Owner

bmatcuk commented May 31, 2020

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!

@bnkai
Copy link
Author

bnkai commented May 31, 2020

@bmatcuk thanks for the update. It seems to work fine in my test cases. I'll report back if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants