goelhardik / ignore

.gitignore based parser implemented in C# according to the .gitignore spec 2.29.2.
MIT License
50 stars 5 forks source link

Invalid regex when using double stars #22

Closed jairbubbles closed 3 years ago

jairbubbles commented 3 years ago

**foo.txt will produce **foo\.txt(/.*)?$ which is not valid:

System.Text.RegularExpressions.RegexParseException
Invalid pattern '**foo\.txt(/.*)?$' at offset 1. Quantifier {x,y} following nothing.
jairbubbles commented 3 years ago

Looks like my fix is not enough, I'm seeing issues with other rules.

Here is a glimpse:

/**/lunr-index.json
/**/*_generated.csproj
private/**.ps
goelhardik commented 3 years ago

Reopening to look at these again.

goelhardik commented 3 years ago

I can take a look probably tomorrow.

goelhardik commented 3 years ago

It's weird there is no documentation about this kind of case private/**.ps. I can see it ignores files like private/aa.ps, thus behaving the same as private/*.ps. Not sure if it's supposed to catch any other cases.

goelhardik commented 3 years ago

Still pending:

private/**.ps
jairbubbles commented 3 years ago

In fact I took the example from a Perforce repository which has similar ignore rules like git. It's not very documented so I'm not sure it's exactly the same behavior.

I feel like we should just make sure it doesn't throw when parsing the rule.