From 35b00bab62b27a137ba27c83f9041a366e364b0e Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 17 Jan 2023 09:45:03 -0800 Subject: [PATCH 1/2] fix case where ) appears in a class in an extglob --- src/index.ts | 3 ++- tap-snapshots/test/basic.js.test.cjs | 8 ++++++++ test/patterns.js | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 9941efbf..78232006 100644 --- a/src/index.ts +++ b/src/index.ts @@ -760,11 +760,12 @@ export class Minimatch { } case ')': { - const plEntry = patternListStack.pop() + const plEntry = patternListStack[patternListStack.length - 1] if (inClass || !plEntry) { re += '\\)' continue } + patternListStack.pop() // closing an extglob clearStateChar() diff --git a/tap-snapshots/test/basic.js.test.cjs b/tap-snapshots/test/basic.js.test.cjs index 1af77ff1..e0eb6cd2 100644 --- a/tap-snapshots/test/basic.js.test.cjs +++ b/tap-snapshots/test/basic.js.test.cjs @@ -193,6 +193,14 @@ exports[`test/basic.js TAP basic tests > makeRe @(.*|js) 1`] = ` /^(?:(?=.)(?:\\.[^/]*?|(?!\\.)js))$/ ` +exports[`test/basic.js TAP basic tests > makeRe @(a|a[(])b 1`] = ` +/^(?:(?=.)(?:(?!\\.)a|(?!\\.)a[(])b)$/ +` + +exports[`test/basic.js TAP basic tests > makeRe @(a|a[)])b 1`] = ` +/^(?:(?=.)(?:(?!\\.)a|(?!\\.)a[\\)])b)$/ +` + exports[`test/basic.js TAP basic tests > makeRe @(js|.*) 1`] = ` /^(?:(?=.)(?:(?!\\.)js|\\.[^/]*?))$/ ` diff --git a/test/patterns.js b/test/patterns.js index fddbe812..bbef1cc9 100644 --- a/test/patterns.js +++ b/test/patterns.js @@ -336,6 +336,9 @@ module.exports = [ // doesn't start at 0, no dice // neg extglobs don't trigger this behavior. ['!(.a|js)@(.*)', ['a.js'], { nonegate: true }], + () => files=['a(b', 'ab', 'a)b'], + ['@(a|a[(])b', ['a(b', 'ab']], + ['@(a|a[)])b', ['a)b', 'ab']], ] Object.defineProperty(module.exports, 'files', { From 040cd419177aac1c50b962e828cd967bad8a178f Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 17 Jan 2023 09:45:40 -0800 Subject: [PATCH 2/2] 6.1.4 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index bc87a5c7..ae46e5df 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "minimatch", - "version": "6.1.3", + "version": "6.1.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "minimatch", - "version": "6.1.3", + "version": "6.1.4", "license": "ISC", "dependencies": { "brace-expansion": "^2.0.1" diff --git a/package.json b/package.json index 440eaad7..804a2c30 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Isaac Z. Schlueter (http://blog.izs.me)", "name": "minimatch", "description": "a glob matcher in javascript", - "version": "6.1.3", + "version": "6.1.4", "repository": { "type": "git", "url": "git://github.com/isaacs/minimatch.git"