Repository navigation
Decode hexadecimal character references with uppercase digits in plist grammars - #316
Draft
Federico Brancasi (federicobrancasi) wants to merge 1 commit into
Draft
Federico Brancasi (federicobrancasi) wants to merge 1 commit into
Federico Brancasi (federicobrancasi) wants to merge 1 commit into
Conversation
…t grammars A `.tmLanguage` (XML plist) grammar can contain a character reference with uppercase hex digits, like `
` (the carriage return of a CRLF line ending) or ` `. vscode-textmate keeps such a reference as the literal text `
` instead of the character. XML allows both cases (`CharRef ::= '&#x' [0-9a-fA-F]+ ';'`), and Python's `plistlib`, for example, decodes `
` to `\r`. A real grammar on GitHub, `smuccione/slang` `LanguageServer/vscode/syntaxes/slang.tmGrammer.tmLanguage`, has 61 of them in `(?x)` patterns such as: Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Federico Brancasi (federicobrancasi)
requested a balanced review from Copilot
November 29, 2026 11:16
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the uppercase hexadecimal character-reference parsing fix.
No open issues 🎉
What changed in this PR
Fixes XML plist grammar parsing so hexadecimal character references with uppercase digits decode correctly, allowing affected grammar patterns to match as intended.
Changes:
- Accepts
A–Falongside lowercase hexadecimal digits in character references. - Adds a regression test verifying that a grammar containing

correctly tokenizes a number.
| File | Description |
|---|---|
src/tests/grammar.test.ts |
Adds an end-to-end tokenization test for uppercase hexadecimal references. |
src/plist.ts |
Expands the hexadecimal reference regex to accept uppercase digits. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A
.tmLanguage(XML plist) grammar can contain a character reference with uppercase hex digits, like
(the carriage return of a CRLF line ending) or . vscode-textmate keeps such a reference as the literal text
instead of the character. XML allows both cases (CharRef ::= '&#x' [0-9a-fA-F]+ ';'), and Python'splistlib, for example, decodes
to\r. A real grammar on GitHub,smuccione/slangLanguageServer/vscode/syntaxes/slang.tmGrammer.tmLanguage, has 61 of them in(?x)patterns such as:In extended mode the leftover
&becomes a literal that the pattern must match, and#xD;starts a comment. So the number rule never matches, and inx = 0x1F + 42;nothing getsconstant.numeric.c. This happens becauseescapeValinsrc/plist.tsdecodes hex references with/&#x([0-9a-f]+);/g, which only accepts lowercase digits.This PR accepts uppercase hex digits in that regex.
How to test
npx vitest runnpx tsc