fix: allow URIs without double slash in Resource and ResourceTemplate (RFC 3986)#297
Open
blackwell-systems wants to merge 1 commit intomodelcontextprotocol:mainfrom
Open
Conversation
… (RFC 3986) The URI regex required "://" after the scheme, rejecting valid URIs like urn:isbn:123, mailto:user@example.com, config:key, and data: URIs. RFC 3986 only requires ":" after the scheme; the "//" is part of the authority component which is optional. Changed both Resource.URI_PATTERN and ResourceTemplate.URI_TEMPLATE_PATTERN to require ":" instead of "://". Adds data-provider tests for URIs without double slash in both classes. Fixes modelcontextprotocol#293
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.
Summary
The URI regex in
ResourceandResourceTemplaterequires://after the scheme, rejecting valid URIs where the hier-part does not start with//. Per RFC 3986, the authority component (and its//prefix) is optional.What breaks
The MCP spec allows custom URI schemes following RFC 3986.
Fix
Changed
://to:in both regex patterns:URIs with
://(likefile://path) continue to match.Test plan
urn:,mailto:,data:, and custom schemes without////phpunit tests/Unit/Schema/)Fixes #293