What is url encoding %2526?

泄露秘密 提交于 2019-12-23 06:56:35

问题


Why is %2526 used instead of %26 to encode an &?

Im invoking a URL to an external site and when I encode the & as %2526 the parameters are passed correctly but when I just use %26 they are not.


回答1:


If you url-encode an ampersand you get %26. If you url-encode %26 you get %2526. Thus, it is url-encoded twice.




回答2:


%25 is the percent character, so %2526 URLDecoded results in

%26

which URLDecoded results in

&

For some reason, the call you make seems to require doubly percent encoded input. Without knowing more about what you're doing, it's impossible to know why, but I guess all is in order.




回答3:


Apparently it gets decoded twice in the process, first from %2526 to %26 and then from %26 to &.
You shouldn't dwell too long on the why; if this works, just use it like this.




回答4:


& is indeed encoded as %26.

You can test it creating an HTML file, opening it in a browser, inputing symbols you need to test and looking at the resulting URL in browser:

<form>
<input type='text' name='qwe'>
<input type='submit'>
</form>



回答5:


If the URL is used in return URL or value of another query string, the Reserved and Excluded characters should be doubled encoded. & is single-encoded as %26 and double-encoded as %2526.



来源:https://stackoverflow.com/questions/9292865/what-is-url-encoding-2526

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