有人知道为什么 FF 将单引号 '
编码为 %27
吗?
单引号应该是 URL 中的有效字符。 事实上,所有其他浏览器 IE7/IE8/Chrome5/Safari4 都可以通过不将单引号编码为 %27 来正常工作。
这是FF的错误,还是我遗漏了一些东西?
我正在使用 FF3.6.1 进行测试
为了方便测试,只需将其添加到 yourpage.html
<script type="text/javascript">
window.alert("this url = " + window.location.href);
</script>
然后转到yourpage.html?test=quote'encoded
FF不会替换地址栏中的url,但会显示:
yourpage.html?test=quote%27encoded
所有其他浏览器都会显示
yourpage.html?test=quote'encoded
谢谢!
最佳答案
Firefox 4(在 Ubuntu 上)也转义了单引号。
Chromium 11.0.696.57 和 Google Chrome 12.0.742.16 都没有!
但是,应该注意的是,所有字符都可以被编码。如果愿意的话,对 A
进行 url 编码是合法的,并且它应该与直接在 URL 中使用 A
完全相同,因此您的代码应该能够处理这两个版本。
来自RFC 1738 :
On the other hand, characters that are not required to be encoded (including alphanumerics) may be encoded within the scheme-specific part of a URL, as long as they are not being used for a reserved purpose.
关于javascript - Firefox 奇怪的 url 中的单引号转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5884469/