Comments (8)
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. }*.{x,y}
from matching }file.y
. It also seems like it could cause false matches (and signed integer overflow?) as well, in the case of something like }foo{a,b
, which has even (but not paired) braces.
from editorconfig-core-c.
Thanks for your many bug reports! How does #54 look to you?
from editorconfig-core-c.
It seems like #54 should fix the integer overflow and false matches, but it still seems to make the escaping more aggressive than necessary.
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 brace_level == 0
(i.e. there's no opening brace to close).
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 struct
instead). Otherwise, I'd start contributing some test cases to cover things like this.
from editorconfig-core-c.
Scratch what I said about integer overflow. The incorrect pairing check doesn't actually lead to overflow -- it just allows brace_level
to possibly go negative, which seems like it would be harmless. I guess the real issue was just the possibility of emitting unpaired parentheses in the generated regex, which #54 seems to also solve.
from editorconfig-core-c.
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 false
).
I just noticed that my brace pairing check allows through unclosed braces if they are nested but the inner level is closed, e.g. {a,b{c,d{e}
. It's not really obvious what the semantics should be in this case. The regex equivalent just causes regcomp()
to return a REG_EPAREN
error code. I guess if people supply badly formed patterns they can't really expect it to match anything.
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?
from editorconfig-core-c.
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?
from editorconfig-core-c.
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.
from editorconfig-core-c.
Fixed by #54
from editorconfig-core-c.
Related Issues (20)
- Bug: Star is not treated as a literal character inside brackets HOT 4
- Bug: 0 is not considered a valid number for {num1..num2} HOT 2
- Please keep CHANGELOG up-to-date for easier downstream parsing HOT 1
- Unchecked malloc return value
- Header files define reserved identifiers
- Usage of atoi() invokes undefined behaviour on integer overflow
- .editorconfig files with syntax errors can cause property lookup to fail, even if the file is in a directory beneath the "root" config HOT 2
- Clarify dependencies
- Glob: Handling of `?` HOT 7
- Chocolatey package is out of date
- Segfault while reading .editorconfig generated by JetBrains IDE HOT 9
- `editorconfig_parse()` leaks memory when no `.editorconfig` files are found or there are no values HOT 1
- 0.12.5: BUILD_STATICALLY_LINKED_EXE=OFF and static library is build and installed HOT 3
- Unexpected behavior on trailing slash HOT 1
- flatpak-builder: 'submodule' is not a git command HOT 1
- Missing MIT license text for CMake_Modules/FindPCRE2.cmake HOT 1
- Path to using a system copy of inih? HOT 2
- Not passing -vsver to subsequent calls of build.ps1
- Path splitting algorithm isn't UNC-aware
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from editorconfig-core-c.