Repository navigation
Fix UTF-8 encoding of MCP resource URI template values - #339846
Merged
Connor Peet (connor4312) merged 2 commits intoOct 22, 2026
Merged
Connor Peet (connor4312) merged 2 commits into
Connor Peet (connor4312) merged 2 commits into
Conversation
Use UTF-8 percent-encoding and count prefix lengths by Unicode code point. Fixes non-ASCII MCP resource-template values reported in microsoft#339843.
Add regressions for UTF-8 encoding and Unicode code-point prefixes; preserve existing ASCII and control-character tests.
Contributor
Author
|
Could a maintainer authorize the fork workflows so the repository checks can run? The 29 targeted tests and changed-file ESLint pass locally; the CLA and dependency checks have passed. The reproduction and validation limits are in the PR description. |
Connor Peet (connor4312)
enabled auto-merge
October 21, 2026 22:21
roblourens
approved these changes
Oct 21, 2026
roblourens
approved these changes
Oct 21, 2026
Anthony Kim (anthonykim1)
approved these changes
Oct 22, 2026
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.
Fixes #339843
Non-ASCII MCP resource-template values currently produce percent-encoded UTF-16 code units:
cafébecomescaf%E9, and an emoji becomes two surrogate escapes. Encode valid Unicode strings as UTF-8 while retaining the existing ASCII punctuation escaping. Count prefix lengths by Unicode code point so a supplementary character remains intact. This follows RFC 6570 §3.2.1.The two added tests cover accented/CJK/supplementary characters, punctuation, and supplementary-character prefixes; all 26 existing tests, including control-character zero-padding, remain unchanged.
Validation:
node test/unit/node/index.js --run src/vs/base/test/common/uriTemplate.test.ts: 29 passing (28 URI-template tests plus the runner's error check); the two additions fail before the fix. Node 24.19.0 on Linux.git diff --check: pass.No Electron/UI or live MCP-server test was run. Malformed lone-surrogate inputs now throw
URIError, as reserved expansion already does; the encoder also string-coerces non-string array elements. Existing reserved-percent and composite-operator behavior is otherwise outside this fix.AI assistance was used for implementation, testing, and an independent review.