在IE10中编码查询字符串参数 [英] encoding of query string parameters in IE10

查看:168
本文介绍了在IE10中编码查询字符串参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到客户的要求,希望能够使用IE10地址栏中的参数输入Web服务的查询字符串并获取服务结果。参数包括希伯来语中的字符串,如:

I got a request from a customer that he wants to be able to type the query string of my web service with parameters in the IE10 address bar and get the service results. The parameters include string in Hebrew, like:

http://mywebsite.com/service.asmx/foo?param1=123&param2=מחרוזתבעברית

对我来说,IE10与其他(普通)浏览器不同, t编码查询字符串参数 - 每个非ansi字符后面?标记将被转为'3f'字节,尽管它确实编码了什么?标记 - 网址本身。

It looks to me that that IE10, unlike other (normal) browsers, won't encode the query string parameters - every non-ansi character that goes after the ? mark would be turned to '3f' byte, though it does encode what goes before the ? mark - the url itself.

例如,如果我尝试到达url(参数是虚构的,url不是,我没有与该网站的连接)

For example, if i try to reach the url (the parameter is imaginary, url is not, and I have no connection with the site)

http://www.shlomo.co.il/pageshe/sales/רכב-למכירה.asp?param=פאראם 

并查看wireshark发送到服务器的字节,显示我

and look in wireshark for the bytes I send to the server, it shows me

你可以看到它用urlen编码的字符串代替URL的希伯来语部分,但用3f代替希伯来参数。

You can see it does substitute the hebrew part of the URL with urlencoded string, but substitutes the hebrew parameters with ?????, which are '3f's.

chrome中的相同字符串将被编码为全部:

The same string in chrome would be encoded in it's entirety:

GET http://www.shlomo.co.il/pageshe/sales/%D7%A8%D7%9B%D7%91-%D7%9C%D7%9E%D7%9B%D7%99%D7%A8%D7%94.asp?param=%D7%A4%D7%90%D7%A8%D7%90%D7%9D HTTP/1.1

我尝试过在win7 / IE10和winXPheb / IE8的机器上。

I tried it on machines with win7/IE10 and winXPheb/IE8.

我的E设置(特别是选中始终显示编码的地址选项,看是否有帮助和重新启动,但没有任何区别):

My IE settings are (especially checked the "Always show encoded addresses option" to see if it helps and restarted, but made no difference):

我试图搜索有关该问题的任何信息,但没有发现太多。

I tried to search around for any info about the issue, but didn't find much of it.

我的问题是:


  • 确实是这样,还是我缺少什么?

  • 这个行为是否记录在任何地方?

  • 是否有IE / Win中的任何设置启用参数编码。

p.s。如果我正在开发客户端/网络ui,我只是urlencode我的查询,但我的客户请求正是将查询粘贴到IE地址栏,这就是为什么我对这个具体行为感兴趣。

p.s. Sure if I was developing the client/web ui, I would simply urlencode my query, but my request from customer was exactly to paste the query to IE address bar, that's why I'm interested in this specific behavior.

谢谢。

推荐答案

是的,你对行为的观察是准确的。 Internet Explorer 10及以下版本遵循用于对URL进行编码的复杂算法。据说这是在Internet Explorer 11中更新,但我发现新的选项似乎不起作用。

Yes, your observation of the behavior is accurate. Internet Explorer 10 and below follow a complicated algorithm for encoding the URL. This was allegedly updated in Internet Explorer 11, but I've found that the new option doesn't seem to work.

始终显示编码地址选项涉及PunyCode是否显示为IDN主机名,并不影响查询字符串。 发送UTF-8网址主要适用于路径的编码,尽管它也可能影响其他编码路径。

The "Always show encoded addresses option" concerns whether PunyCode is shown for IDN hostnames, and does not impact the query string. Send UTF-8 URLs mostly applies to the encoding of the path, although it can also affect other codepaths

行为没有完全记录在任何地方。我想在IEInternals博客上写一个完整的帖子,但是在这样做之前最终还是从微软开始。在这篇博文

The behavior isn't fully documented anywhere. I'd meant to write a full post on my IEInternals blog about it but ended up moving on from Microsoft before doing so. There's a partial explanation in this blog post.

是的,有一些影响行为的设置。 工具>Internet选项>高级中的发送UTF-8 URL 复选框是确定URL发送方式的变量之一,但该选项不会盲目地执行其意义(它只有UTF-8编码路径,而不是查询字符串)。涉及的其他变量包括:

Yes, there are settings that impact the behavior. The Send UTF-8 URLs checkbox inside Tools > Internet Options > Advanced is one of the variables that determines how URLs are sent, but the option does not blindly do what it implies (it only UTF-8 encodes the path, not the query string). Other variables involved include:


  1. URL的输入位置(例如地址栏与开始>运行等)

  2. 系统的ANSI代码页是什么(例如,默认情况下使用的是什么语言环境)

  3. 浏览器中当前加载的页面的字符集

由于这些变量的结果,您无法在Internet Explorer中使用未正确编码的URL(例如,%转义的UTF8)。

As a consequence of these variables, you cannot reliably use URLs which are not properly encoded (e.g. %-escaped UTF8) in Internet Explorer.

这篇关于在IE10中编码查询字符串参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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