c++urliisisapi

Server variable UNENCODED_URL contains strange value instead of encoded slash


We have a legacy IIS DLL that uses GetServerVariable (MSDN) to retrieve the value of UNENCODED_URL. When accessing the URL:

https://example.com/a%2Fb

the value retrieved will look like this:

/path/to/server.dll/a0.000000b

which is strange, because it should look like this:

/path/to/server.dll/a%2Fb

The LPEXTENSION_CONTROL_BLOCK's value of lpszPathInfo (MSDN) has the value:

/a/b

as expected.

Does anybody know why the UNENCODED_URL value looks like this and how can I retrieve the correct value?


Solution

  • If you’re using for example printf to output the value of the environment variable instead of using a debugger, or puts, that will explain it. %2f will be understood as a command to printf to output the first variable argument as a floating point number.

    Always output strings with puts or other functions that do not alter the value.