diff --git a/__tests__/internal-pattern.test.ts b/__tests__/internal-pattern.test.ts index 1c52543..2f101d9 100644 --- a/__tests__/internal-pattern.test.ts +++ b/__tests__/internal-pattern.test.ts @@ -342,6 +342,13 @@ describe('pattern', () => { expect(pattern.match('C:/foo/b/ar/baz')).toBeTruthy() // Regression testing for minimatch v3 + // Historically, minimatch/glob had a bug when parsing a character class + // containing an escaped '!' (e.g. `[\\!]`). In some cases, the internal + // pattern construction would incorrectly insert the literal string + // "undefined" into the generated pattern/segment, which could make a + // pattern intended to match `b[\\!]r` also match a path segment like + // `b[undefined/!]r`. This test ensures that a pattern with a literal + // `[\\!]` in the directory name does *not* match such malformed paths. pattern = new Pattern('C:/foo/b[\\!]r/b*') expect(pattern.searchPath).toBe('C:\\foo\\b[\\!]r') expect(pattern.match('C:/foo/b[undefined/!]r/baz')).toBeFalsy()