micromatch / braces

Faster brace expansion for node.js. Besides being faster, braces is not subject to DoS attacks like minimatch, is more accurate, and has more complete support for Bash 4.3.
https://github.com/jonschlinkert
MIT License
207 stars 47 forks source link

quotes #3

Closed isaacs closed 8 years ago

isaacs commented 9 years ago

Brace patterns within quoted sections should not be expanded.

$ echo "{a,b}{{a,b},a,b}"{x,y}
{a,b}{{a,b},a,b}x {a,b}{{a,b},a,b}y

$ node -p 'require("./")("\"{a,b}{{a,b},a,b}\"{x,y}")'
[ '"aa"x',
  '"ab"x',
  '"ba"x',
  '"bb"x',
  '"aa"y',
  '"ab"y',
  '"ba"y',
  '"bb"y' ]
jonschlinkert commented 9 years ago

k, I'll mark as a bug.

for reference, this is what minimatch renders on the same:

[ '"aa"x',
  '"aa"y',
  '"ab"x',
  '"ab"y',
  '"aa"x',
  '"aa"y',
  '"ab"x',
  '"ab"y',
  '"ba"x',
  '"ba"y',
  '"bb"x',
  '"bb"y',
  '"ba"x',
  '"ba"y',
  '"bb"x',
  '"bb"y' ]
jonschlinkert commented 9 years ago

here are the failing tests, I thought I had a failing unit test for this already, I don't see it though. I'll get this added either way, just don't want to duplicate. thx

jonschlinkert commented 9 years ago

ah, nvm here they are: https://github.com/jonschlinkert/braces/blob/minimatch/test/fixtures/failing.js#L12-L13.

@isaacs I'm curious though, what is the use case for this? Given that it's not supported by minimatch currently, and this seems like a super-brittle feature to implement given that patterns might normalized or people will expect to be able to use double or single quotes, etc. if it's worth the added code complexity to support this and/or a requirement of minimatch, I'll implement it. just want your feedback before I put time into solving...

jonschlinkert commented 9 years ago

actually, looking over the spec I don't see that anywhere. Can you point it out to me? I see

'{"x,x"}'

but not

'"{x,x}"'
isaacs commented 9 years ago

At this point, I'm just looking for cases where bash 4.3's behavior differs from braces. Once braces implements it exactly the same as bash, I'll pull it into minimatch. It should be a major-version-bump for both.

If you're opposed to this plan, I'm happy forking it and going my own way. But if you're cool with it, I'd love to collaborate. Just don't want to be presumptuous if you have a different vision for this thing, especially if it ends up adding complexity or reducing performance, since "simple + fast" seem to be key priorities for braces.

jonschlinkert commented 9 years ago

Once braces implements it exactly the same as bash

Absolutely fair. In case my comment came of as a challenge, I was really trying to learn!

But if you're cool with it, I'd love to collaborate.

Absolutely interested!

since "simple + fast" seem to be key priorities for braces.

It was when I created it, given my frame of reference at the time. Now I'm just having fun trying to improve my own code. I'm pretty easy going. I think my code always turn out better (faster or not) when I'm having fun. and I really love this stuff lol