fix: URL-decode parameters extracted from resource templates #1864
+85
−2
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
URL-decode parameters extracted from resource template URIs so that percent-encoded characters (like
%20for space,%C3%A9foré) are properly decoded before being passed to resource handlers.Motivation and Context
When a client requests a resource using a URI like
search://hello%20world, the{query}parameter was being passed to the handler as the literal string"hello%20world"instead of"hello world". This broke handlers that expected decoded strings.Fixes #973
How Has This Been Tested?
Added
tests/issues/test_973_url_decoding.pywith 4 test cases:%20→)%C3%A9→é)+remains as+(correct URI behavior vs form encoding)Breaking Changes
None. This is a bug fix that makes resource templates work as users would expect.
Types of changes
Checklist
Additional context
Uses
urllib.parse.unquotewhich handles UTF-8 encoded characters correctly. The+sign is intentionally NOT converted to space because that behavior is specific toapplication/x-www-form-urlencoded(HTML forms), not URI encoding.