microsoft / microsoft/vscode-textmate
Escaping a `]` inside a posix class `[[:\]:]` does funky stuff
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 678
- Forks
- 135
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 2
Description
The regex [[:upper:]] works as expected at matching only upper case letters.
Normally if you missspell anything inside the posix class, the textmate engine will fail. Except for a few noteble expcetions; ], : and [: (only gonna focus on ] for now)
[[:upp]er:]] will work with matching :], u], p], e] and r]. (regex: [:uper]\]).
But if you escape the ] inside the posix class, then both square brackets acts as both the closing and opening brackets for the 2nd character class and as literary characters for the 1st class. Leaving the last ] competely out of the classes (and can be removed without error).
[[:upp\]er:]] will match the same as above but also with the added [ and ].
:], u], p], e] r] [] and ]]. (regex:[\[:uper\]]\]).
[[:\]:] will match [, : and ].
Placing a (EDIT: - before the last : causes textmate engine to fail [[:\]-:].\]-: is an illegal character range)
Regex works as expected if either : is removed or moved one space away from their respected square bracket.
(I have used a single \ instead of the required double \\ from json embeding)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the [[:upper:]], [[:upp\]er:]], and [[:\]:] examples against vscode-textmate and compare the reported matches. Start by tracing how the library handles these POSIX character-class patterns; done means the escaping behavior is defined and the reproduced cases no longer produce unintended matches. The issue has no file or test location, so the relevant entry point must be located first.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100