EscapeDataString having differing behaviour between Powershell IDE and Powershell console

蹲街弑〆低调 提交于 2019-12-06 23:30:56

问题


I'm a bit confused with this issue! I'm building a bigger script and it was working in the ISE but not in a powershell console. I've managed to track it down to the [System.Uri]::EscapeDataString function which seems to be behaving differently between the different environments, for example in my powershell console () ' & ! are not being escaped, where as in the IDE they are all being escaped.

Am I missing something?

My test code:

[System.Uri]::EscapeDataString("/?:@%!$&'/*+,;=()")

ISE output:

%2F%3F%3A%40%25%21%24%26%27%2F%2A%2B%2C%3B%3D%28%29

Powershell Console output:

%2F%3F%3A%40%25!%24%26'%2F*%2B%2C%3B%3D()

Thanks!


回答1:


Here is the difference, per the source: [System.UriParser].GetField('s_QuirksVersion', [Reflection.BindingFlags] 'Static, NonPublic').GetValue($null).

I marked the answer as community wiki because it appeared in the comments, causing the question to appear in searches for unanswered questions.



来源:https://stackoverflow.com/questions/41959310/escapedatastring-having-differing-behaviour-between-powershell-ide-and-powershel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!