为什么Uri.EscapeDataString与我的开发机器相比在我的CI服务器上返回不同的结果? [英] Why does Uri.EscapeDataString return a different result on my CI server compared to my development machine?

查看:117
本文介绍了为什么Uri.EscapeDataString与我的开发机器相比在我的CI服务器上返回不同的结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



var result = Uri.EscapeDataString(zdskjhf& * ^ 65sdfh /.& ;> \\sdf);
// result == zdskjhf%26%2A%5E65sdfh%2F。%3C%3E%5Csdf



现在,我的CI服务器部分的结果没有编码....
我得到这个



\\ \\\ result == zdskjhf%26 *%5E65sdfh%2F。%3C%3E%5Csdf



注意星号在第二个结果的中间?



任何人都可以解释发生了什么吗?



更新1 :



这是一个.NET Fiddle ,它正在使用.NET 4.5并显示星号已编码...



所以这意味着我的机器 .NET Fiddle都是错误的?或者我们都是对的,CI服务器是错误的?



来自构建服务器的一些诊断信息..

Microsoft (R)Build Engine版本12.0.30723.0
[Microsoft .NET Framework,版本4.0.30319.34209]
版权所有(C)Microsoft Corporation。版权所有。



(我不太确定如何获取这个信息,对于我的本地开发机器,它是win8.1 + VS 2013 Update 3。)



所有项目都是.NET 4.5 ... 4.5.1



更新2:



我已经决定在所有的.NET框架上运行这个代码(很重要)。
这是结果。

 数据:abcde *。(。)

.NET 2.0:abcde%20 *。(。)
.NET 3.0:abcde%20 *。(。)
.NET 3.5:abcde%20 *。(。)
.NET 4.0:abcde%20 *。(。)。

- MSDN注意:现在修复错误 -

.NET 4.5:abcde%20%2A 。%28.%29。
.NET 4.5.1:abcde%20%2A。%28.%29。
.NET 4.5.2:abcde%20%2A。%28.%29 。
.NET 4.5.3:abcde%20%2A。%28.%29。

然后建议




  • < .NET 4.5 ,这些值没有编码,Kewl,好的。


  • = .NET 4.5 这些值被编码。





LINK:这是一个类似的SO问题

REF:这是CI服务器的构建结果 ch包含很多调试信息...

解决方案

。NET 4.5改变了这种方法的行为。搜索 escape 。 / p>

On my desktop machine, I get this..

var result = Uri.EscapeDataString("zdskjhf&*^65sdfh/.<>\\sdf"); // result == zdskjhf%26%2A%5E65sdfh%2F.%3C%3E%5Csdf

Now, on my CI server part of the result is NOT encoded.... I get this

\\ result == zdskjhf%26*%5E65sdfh%2F.%3C%3E%5Csdf

Notice the asterisk in the middle of the second result? in the first result, it's getting encoded.

Can anyone explain what's going on, please?

Update 1:

Here's an .NET Fiddle which is using .NET 4.5 and shows the asterisk is encoded...

So does this mean my machine and .NET Fiddle are both wrong ? Or we are both right and the CI Server is wrong?

Some diagnostic info from the build server..
Microsoft (R) Build Engine version 12.0.30723.0 [Microsoft .NET Framework, version 4.0.30319.34209] Copyright (C) Microsoft Corporation. All rights reserved.

(i'm not too sure how to get this info, for my local dev machine. It's win8.1 + VS 2013 Update 3.)

All projects are .NET 4.5 ...not 4.5.1

Update 2:

I've decided to run this code on all the .NET frameworks (that matter). Here's the results.

Data:     abcde *.(.)."

.NET 2.0: abcde%20*.(.).
.NET 3.0: abcde%20*.(.).
.NET 3.5: abcde%20*.(.).
.NET 4.0: abcde%20*.(.).

-- MSDN NOTES: Bug now fixed here --

.NET 4.5:   abcde%20%2A.%28.%29.
.NET 4.5.1: abcde%20%2A.%28.%29. 
.NET 4.5.2: abcde%20%2A.%28.%29. 
.NET 4.5.3: abcde%20%2A.%28.%29.

This then suggests that

  • < .NET 4.5, those values are NOT encoded. Kewl, fine.
  • = .NET 4.5 those values ARE encoded.

LINK: this is a similar SO question.
REF: this is the build result from the CI server which includes lots of debug info...

解决方案

.NET 4.5 changed the behavior of this method. Search for "escape".

这篇关于为什么Uri.EscapeDataString与我的开发机器相比在我的CI服务器上返回不同的结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆