Skip to content
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

werkzeug double-encodes redirects when processing merge_slashes #2157

Closed
tomprince opened this issue Jun 8, 2021 · 1 comment
Closed

werkzeug double-encodes redirects when processing merge_slashes #2157

tomprince opened this issue Jun 8, 2021 · 1 comment
Milestone

Comments

@tomprince
Copy link

from werkzeug.routing import Rule, Map

routes = Map([
    Rule("/merge/<some>/path"),
])

def get_redirect_location(path):
    try:
        routes.bind("test.host").match(path)
    except Exception as e:
        return e.get_response({}).headers['location']
    else:
        raise ValueError("no redirect")

def test_merge_slashes():
    assert get_redirect_location("/merge/%//path") == 'http://test.host/merge/%25/path'

It looks like Rule.match uses Rule.build to generate the new path here, which is already urlencoded. But then MapAdapter.match encodes the resulting path again here.

Environment:

  • Python version: 3.9.5
  • Werkzeug version: 2.0.1
@cAtaman
Copy link
Contributor

cAtaman commented Jul 24, 2021

I just opened #2193 which should fix this

@davidism davidism added this to the 2.0.2 milestone Aug 5, 2021
@davidism davidism closed this as completed Aug 5, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants