Skip to content

Commit

Permalink
fix: unescape bracket validation
Browse files Browse the repository at this point in the history
  • Loading branch information
MrGriefs authored and isaacs committed Dec 14, 2022
1 parent 493a42f commit 50eccc7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion minimatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ minimatch.match = (list, pattern, options = {}) => {
// replace stuff like \* with *
const globUnescape = s => s.replace(/\\(.)/g, '$1')
const regExpEscape = s => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')
const braExpEscape = s => s.replace(/[[\]\\]/g, '\\$&')

class Minimatch {
constructor (pattern, options) {
Expand Down Expand Up @@ -615,7 +616,7 @@ class Minimatch {
// to do safely. For now, this is safe and works.
cs = pattern.substring(classStart + 1, i)
try {
RegExp('[' + cs + ']')
RegExp('[' + braExpEscape(globUnescape(cs)) + ']')
} catch (er) {
// not a valid class!
sp = this.parse(cs, SUBPARSE)
Expand Down

0 comments on commit 50eccc7

Please sign in to comment.