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

Path with URL encoded forward slash is being decoded before determining the route #1464

Open
jkr-acp opened this issue Dec 17, 2024 · 0 comments
Labels

Comments

@jkr-acp
Copy link

jkr-acp commented Dec 17, 2024

Describe the Bug

If an URL contains a encoded forward slash (e.g. /job/john%2f117) and a route like /job/:jobName exists, the route is never hit because the server decodes the forward slash before determining the correct route.
The requests log shows GET /job/john/117 HTTP/1.1 404

In our case we have a route group with several routes like /job/:jobName, /job/:jobName/objects, etc.
As the values of jobName came from another system, which we can't influence, some names contains a forward slash.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Create a server file with the following content.
    Start-PodeServer {
        Add-PodeEndpoint -Address "127.0.0.1" -Port 8080 -Protocol Http
    
        Add-PodeRoute -Method Get -Path "/job/:jobName" -ScriptBlock {
            $JobName = $WebEvent.Parameters["jobName"]
            Write-PodeJsonResponse -Value @{"message" = "jobname route for $($JobName) was reached."}
        }
    
        Add-PodeRoute -Method Get -Path "/job/:jobName/objects" -ScriptBlock {
            $JobName = $WebEvent.Parameters["jobName"]
            Write-PodeJsonResponse -Value @{"message" = "objects route for $($JobName) was reached."}
        }
    }
  2. Try to access the URL http://localhost:8080/job/John%2f117
  3. Observe the 404 with the false decoded URL

Expected Behavior

A JSON response should be returned:

{"message": "jobname route for John/117 was reached."}

Platform

  • OS: Windows
  • Browser: Chrome, Firefox, etc.
  • Versions:
    • Pode: Pode v2.11.1
    • PowerShell: PowerShell 5.1

Additional Context

Issue #558 and PR #560 are related, since this PR included the [System.Web.HttpUtility]::UrlDecode method for the URI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Backlog
Development

No branches or pull requests

1 participant