microsoft / microsoft/vscode-textmate

Escaping a `]` inside a posix class `[[:\]:]` does funky stuff

Open
#165 4 comments 1 reaction 0 assignees View on GitHub

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 - before the last : causes textmate engine to fail [[:\]-:]. (EDIT: \]-: 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.