Firefox 自动解码 URL? CodeIgniter允许的字符问题
当我在 w3schools 上访问这个地址时,当我按下 Enter 键加载页面时,地址中的 %28 会自动解码为 ( 在 Firefox 地址栏中。
http://www.w3schools.com/TAGS/html_form_submit.asp?text=%28Hello+G
但是,当访问这个地址时(末尾有一个额外的 %),该地址是没有在地址栏中重写。
http://www.w3schools.com/TAGS/html_form_submit.asp?text=%28Hello+G%
任何人都可以解释这种行为吗?它导致我正在处理的 AJAX 调用出现问题(当我发出请求时,来自 document.location.hash 值编码的字符会被自动解码,因为我我使用 CodeIgniter 不允许解码字符。
When visiting this address on w3schools the %28 in the address is automatically decoded to ( in the Firefox address bar as soon as I press enter to load the page.
http://www.w3schools.com/TAGS/html_form_submit.asp?text=%28Hello+G
However, when visiting this address (an extra % at the end) the address is not rewritten in the address bar.
http://www.w3schools.com/TAGS/html_form_submit.asp?text=%28Hello+G%
Can anyone explain this behavior? It is causing problems with an AJAX call I am working on (when I make a request a web page from document.location.hash value encoded characters are being automatically decoded and because I am using CodeIgniter the decoded characters are not allowed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Firefox 仅解码有效地址,因此“text=%28Hello+G%”将保持不变(正确编码的“%”字符为“%25”)。
可能的解决方案:
使用url安全base64(http://www.php.net/manual/en/function.base64-encode.php#103849)而不是urlencode对你的url进行编码
在urlencoding后将“%”字符更改为其他内容
Firefox is decoding only valid addresses, therefore "text=%28Hello+G%" will remain unchanged (properly encoded "%" character is "%25").
Possible solutions:
encode your urls with url safe base64 (http://www.php.net/manual/en/function.base64-encode.php#103849) instead of urlencode
change "%" characters into something else after urlencoding