dazinator / DotNet.Glob

A fast globbing library for .NET / .NETStandard applications. Outperforms Regex.
MIT License
363 stars 27 forks source link

Incorrect match with ** #65

Closed tompittson closed 5 years ago

tompittson commented 5 years ago

Hello,

Trying something out with your library I found the following pattern doesn't match as expected.

var glob = DotNet.Globbing.Glob.Parse("abc/**");

// success - expected
Assert.IsTrue(glob.IsMatch("abc/def/hij.txt"));

// failure - unexpected
Assert.IsFalse(glob.IsMatch("abcd"));

I have tried this with 2.1.1 stable and 3.0.0 alpha045 versions. I noticed there was a similar bug (#33) which mentions a GlobParseOptions setting around invalid path characters but I can't see that setting in the GlobOptions at the latest versions.

dazinator commented 5 years ago

Thanks for reporting, I'll investigate!

dazinator commented 5 years ago

@tompittson - Thanks for raising this, good find. I have fixed this bug which was manifesting when ** was being matched against the last character of a test string causing in some cases a false positive match. I have added test coverage for this, and it's fixed in 2.1.2 or latest alpha.

dazinator commented 5 years ago

Correction: version 2.1.3 ended up being the released hotfix version as I also had to fix an issue with the appveyor build.

tompittson commented 5 years ago

@dazinator thanks for looking at this, I have tried the newest versions (2.1.3 and 3.0.1) and the original issue is fixed but it seems to have introduced a couple of additional issues.

"a/b" is now not matched by pattern "a/**/b"
"abc/def" matched against the pattern "abc/**" throws an 'Index was outside the bounds of the array' exception.
dazinator commented 5 years ago

Hmm.. apologies for this.. It seems I was too confident in my existing test coverage when making those tweaks to fix that last bug.. I'll add these test cases, and release an update!

dazinator commented 5 years ago

Thanks for your patience with this one, I have now fixed this regression in 2.1.4 - and added your repro examples to the regression suite.