-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Brace pairing check in ec_glob.c incorrect? #50
Comments
It seems if the braces are (incorrectly) determined to be "paired", all braces in the pattern get escaped and only represent themselves. That seems to prevent e.g. |
Thanks for your many bug reports! How does #54 look to you? |
It seems like #54 should fix the The approach I took is to find the last index at which there is a paired, closing brace and beyond that point just escape all braces. Closing braces before that point also get escaped (represent themselves) if The over-escaping issue is more of a question of semantics though and not necessarily a bug. I haven't started using the editorconfig test cases yet because they're rather hard to separate from CMake and seem to require an implementation that retains all of the parsed properties as a dictionary instead of just cherry-picking the ones it's interested in (so it can use a |
Scratch what I said about integer overflow. The incorrect pairing check doesn't actually lead to overflow -- it just allows |
I've been thinking about this some more and I'm starting to think your approach of "over-escaping" might actually be the best thing to do. Either that or just make patterns with invalid brace pairing match nothing (always return I just noticed that my brace pairing check allows through unclosed braces if they are nested but the inner level is closed, e.g. tl;dr I think your PR #54 seems fine. My only remaining question is -- should badly paired braces just cause the pattern to match nothing at all instead? |
I'm personally leaning toward not making incompatible changes unless there is a compelling reason. In this case, it would be keep unpaired curly braces match. What do you think? |
If someone authors a pattern with unpaired braces by mistake, the net result is probably that it just doesn't match what they wanted it to (or anything at all). So long as there are no exploits in the implementation, either behaviour seems fine to me. I'll just copy whatever upstream decides on. |
Fixed by #54 |
I was just reading the code in
ec_glob.c
and noticed this loop doesn't seem to be doing what the variable name would suggest. Checking for equal numbers of opening and closing braces doesn't necessarily mean they're "paired". It's not immediately obvious if or how this effects the correctness of the code, but I just thought I'd point it out in case it's a bug.The text was updated successfully, but these errors were encountered: