-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
Escaped braces aren't handled properly #56
Comments
Hmm, are you using doublestar v4? What OS are you on? How are you building your pattern? You'll need to double the backslashes to get them to stay in the string, ie I cannot reproduce this issue using v4 on macOS. |
I think I was maybe mistaken as to the exact issue – there is an issue with both copied for referencepackage main
import (
"fmt"
"github.com/bmatcuk/doublestar/v4"
)
func main() {
patterns := []string{
//`\{????-??-??\}.txt`,
//`\[????-??-??\].txt`,
`\{*\}.txt`,
`\[*\].txt`,
}
names := []string{
`{2021-05-01}.txt`,
`[2021-05-01].txt`,
`normal text`,
}
for _, p := range patterns {
for _, n := range names {
match, err := doublestar.Match(p, n)
fmt.Println(p, n, match, err)
}
}
}
/* output
\{*\}.txt {2021-05-01}.txt true <nil>
\{*\}.txt [2021-05-01].txt false syntax error in pattern
\{*\}.txt normal text false syntax error in pattern
\[*\].txt {2021-05-01}.txt false syntax error in pattern
\[*\].txt [2021-05-01].txt true <nil>
\[*\].txt normal text false syntax error in pattern
*/ |
@bmatcuk I found the issue – every iteration of the loop consuming pattern validates the remaining pattern: Lines 279 to 281 in 1fd2e2d
The Lines 241 to 245 in 1fd2e2d
Why validate the pattern every loop? |
Hey @micimize! I'm so sorry I didn't see your reply back in May! I never got a notification from github that you replied! Your test cases were most helpful and I was able to fix the bug fairly quickly. I only wish I would have seen your reply a month ago so I could have fixed it then 😢 Anyway, I just released v4.0.2 with the fix. Let me know if you have any trouble with it. By the way, |
I'm going to close this issue since there hasn't been any activity. Let me know if you run into trouble with the fix! |
will do! Sorry I haven't gotten around to actually testing it but will ping here if there are any issues when I do |
It seems that
\{
and\}
are not handled properly in both pattern patching and path evaluation:**/log file \{????-??-??\}.txt
will fail with a syntax errorsrc/logs/log file {2021-05-11}.txt
will fail with any pattern (this is a valid path)If I remove both from my test the other patterns and path combinations work fine. This does not seem to be the case for brackets, e.g.
src/logs/log file [2021-05-11].txt
and
**/log file [????-??-??].txt
. I am usingdoublestar.Match
.The text was updated successfully, but these errors were encountered: