question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

URI-encoded path parameters get broken

See original GitHub issue

Hi,

I submit a string containing the ‘/’ character with Swagger UI in the browser (as a path parameter). When I receive the string in req.params, the string contains the URI-encoded ‘%2F’.

I was debugging into the source code and found out that the req.params (which are URI-decoded by Express) are overwritten with the original (not URI-decoded) values. The params are overwritten in the file src/index.ts, line 140 of Commit 00273f7

``

  if (openapi?.pathParams) {
    const { pathParams } = openapi;
    // override path params
    req.params[name] = pathParams[name] || req.params[name];
  }

``

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
TorstenForthcommented, Mar 9, 2020

@cdimascio Thank you very much. It works well now.

0reactions
cdimasciocommented, Mar 7, 2020

@TorstenForth i had a look at this issue. it should be resolved now. see v3.9.4. let me know how it goes. thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

broken auto-decoding urlencoded named path parameters #878
Param("s") don't decode param if it encoded with urlencode Steps to reproduce ... broken auto-decoding urlencoded named path parameters #878.
Read more >
Java URL encoding of query string parameters - Stack Overflow
I have used URI.create and replaced spaces with + in querystring. At the client site it converted + back to spaces when I...
Read more >
API using url encoded paths is broken (#18775) - GitLab.org
It seems like you have to have some additional settings in the NGINX config to allow the encoded params to pass. Is the...
Read more >
encodeURIComponent() - JavaScript - MDN Web Docs
A string to be encoded as a URI component (a path, query string, fragment, etc.). Other values are converted to strings.
Read more >
parse_url - Manual - PHP
This function parses a URL and returns an associative array containing any of the various components of the URL that are present. The...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found