Fix: Correct URI query parameter matching and class name typo (Fixes #596) #599
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.
Motivation and Context
This pull request addresses two separate issues, with the primary goal of resolving issue #596.
Fixes: #596
URI Matching Bug: A critical bug was identified in
DefaultMcpUriTemplateManager.matches()
where it would fail to correctly match any URI template containing a query parameter (e.g.,file://name/search?={search}
). The root cause was the unescaped?
character being misinterpreted as a special character by the regex engine.Class Name Typo: Incorporates a pending change to correct a persistent spelling mistake in a core factory class name (
DefaultMcpUriTepmlateManagerFactory
).Description of Changes
Bug Fix: The
matches
method inDefaultMcpUriTemplateManager
has been rewritten to use a robust regex-building approach withPattern.quote()
. This ensures that all literal parts of the URI template, including special characters like?
, are properly escaped before the matching pattern is compiled. The logic now mirrors the safer implementation already used in theextractVariableValues
method.Typo Fix: The class
DefaultMcpUriTepmlateManagerFactory
has been renamed toDefaultMcpUriTemplateManagerFactory
, and all references to it have been updated throughout the codebase.How Has This Been Tested?
shouldMatchUriWithQueryParameters
andshouldExtractVariableValuesFromUriWithQueryParameters
) were added to specifically reproduce the URI matching bug.Breaking Changes
[x] Yes. Any user directly referencing the misspelled class
DefaultMcpUriTepmlateManagerFactory
will need to update their code to use the corrected class nameDefaultMcpUriTemplateManagerFactory
after pulling this change.Types of changes
Checklist
Additional context
This is a straightforward find-and-replace action to correct a typo. No other logic or functionality has been altered.