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

get an unencoded url from Url Rewrite IIS module #486

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

eugeneagafonov
Copy link

url rewrite module normalizes some encoded paths in url. To get the original request url we need to get it from UNENCODED_URL server variable. Since I'm not a pro C++ developer please review the code thoroughly.

This will resolve these issues:
Url encoded characters get decoded
URLEncoded route parameters are not respected #217

@bdoss
Copy link

bdoss commented Mar 12, 2016

Ran into this issue as well. Your commit here seems to resolve the issue I was seeing with encoded forward slashes getting decoded. Thanks!

@HCanber
Copy link

HCanber commented Apr 7, 2016

It seems more reasonable to use UNENCODED_URL.
HTTP_X_ORIGINAL_URL is decoded (a bit contradictory, given the name).

The URL Rewrite Module preserves the original requested URL path in the following server variables:

  • HTTP_X_ORIGINAL_URL – this server variable contains the original URL in decoded format;
  • UNENCODED_URL – this server variable contains the original URL exactly as it was requested by a Web client, with all original encoding preserved.

http://www.iis.net/learn/extensions/url-rewrite-module/url-rewrite-module-configuration-reference#Preserving_Original_URL

…if anyone needs to work with the raw request url
@eugeneagafonov
Copy link
Author

It appeared that url decoding was due to security issues involved, so I added a config value useUnencodedRequestUrl which is disabled by default. It can be enabled by adding iisnode.yml file to the web site root with the following content

# useUnencodedRequestUrl - controls whether iisnode gets request url from X-Original-URL server variable that gets sanitized by http.sys
# or from UNENCODED_URL, which represents an exact original url. Using the latter option means that the application itself will be
# responsible for possible security issues

useUnencodedRequestUrl: true

@SomaticIT
Copy link

👍

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

Successfully merging this pull request may close these issues.

4 participants