Skip to content

Encode supplementary characters in reserved URI template expansion - #1931

Open
pournasserian wants to merge 5 commits into
modelcontextprotocol:mainfrom
pournasserian:feat/csharp-sdk-mcp-issue-a107fa
Open

pournasserian wants to merge 5 commits into
modelcontextprotocol:mainfrom
pournasserian:feat/csharp-sdk-mcp-issue-a107fa

Conversation

@pournasserian

Copy link
Copy Markdown
Contributor

Fixes #1913

Reserved ({+var}) and fragment ({#var}) expansion in UriTemplate.Encode built a Rune from each UTF-16 char. For a surrogate pair (for example, an emoji), that throws ArgumentOutOfRangeException. On netstandard2.0 it didn't throw, but each half was encoded as U+FFFD. The encoder now encodes the full pair as one UTF-8 scalar.

Tests: added ReservedExpansion_EncodesSupplementaryUnicodeScalar covering {+}, {#} and mixed BMP/supplementary values. It fails without the fix and passes with it on net10.0, net9.0, net8.0 and net472.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant