Skip to content

Incorrect Reserved Expansion #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
watuwo opened this issue Nov 5, 2022 · 0 comments
Closed

Incorrect Reserved Expansion #99

watuwo opened this issue Nov 5, 2022 · 0 comments
Labels

Comments

@watuwo
Copy link

watuwo commented Nov 5, 2022

Valid UTF-8-percent-encoded code points must be preserved in reserved expansion. This implementation (Version: 4.1.1) fails the following test from https://github.com/uri-templates/uritemplate-test/blob/master/extended-tests.json:

{
  ...
  "Additional Examples 6: Reserved Expansion": {
    "variables" : {
      "id" : "admin%2F",
      ...
  },
  "testcases": [
    ["{+id}", "admin%2F"],
    ...
  ]
}

The correct/expected expansion is 'admin%2F', the actual expansion is 'admin%252F':

>>> from uritemplate import URITemplate, expand
>>> URITemplate('{+id}').expand(id='admin%2F')
'admin%252F'
>>> expand('{+id}', id='admin%2F')
'admin%252F'
sigmavirus24 added a commit that referenced this issue May 29, 2025
This demonstrates the bug in #99
sigmavirus24 added a commit that referenced this issue Jun 2, 2025
With a small refactor, and some better logic and naming, we can easily
fix the issue of double escaping %s in strings they should not be
escaped in.

Closes #99
sigmavirus24 added a commit that referenced this issue Jun 2, 2025
With a small refactor, and some better logic and naming, we can easily
fix the issue of double escaping %s in strings they should not be
escaped in.

Closes #99
sigmavirus24 added a commit that referenced this issue Jun 2, 2025
With a small refactor, and some better logic and naming, we can easily
fix the issue of double escaping %s in strings they should not be
escaped in.

Closes #99
sigmavirus24 added a commit that referenced this issue Jun 2, 2025
With a small refactor, and some better logic and naming, we can easily
fix the issue of double escaping %s in strings they should not be
escaped in.

Closes #99
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Jun 4, 2025
4.2.0 - 2025-06-01

- Drop support for Python 3.8
- Fix bug where already url-encoded values were further escaped and
  encoded (See python-hyper/uritemplate#99)
- Refactor ``uritemplate/variable.py`` to enable fixing the
  aforementioned bug.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants