2015-09-07 98 views
0

被双重编码,我有一个自定义的用户密码重置页面,它工作得很好,发送一封电子邮件,一个独特的URL将密码重置如:网址是在WordPress的

https://website.org/reset-password?action=rp&key=chMOWDgCb8h7eFZZby1w&login=Test%20User 

当我把网址浏览器,我指向:

https://website.org/reset-password?action=rp&key=chMOWDgCb8h7eFZZby1w&login=Test%2520User 

如果我手动从%252025的URL的作品,但我不能找出如何保持它的双编码的字符。

回答

3

这是因为%20被编码为文字%20而不是空格。

因此,当你生成你的链接应该是:

your_function_to_generate_password_link('https://website.org/reset-your-password?action=rp&key=chMOWDgCb8h7eFZZby1w&login=Test User'); 

而不是:

your_function_to_generate_password_link('https://website.org/reset-your-password?action=rp&key=chMOWDgCb8h7eFZZby1w&login=Test%20User'); 

我怀疑你现在正在做这样的事情(或WordPress是其编码) :

htmlentities($yourpasslink); 

而且链接本身包含%20而不是一公升空间:

如果你运行ヶ辆的两倍,这是发生了什么:

$test = " "; 
$first_try = htmlentities($test); // outputs %20 
echo $first_try; // outputs %20 
echo htmlentities($first_try); // outputs %2520 

%25%实体代码和20不需要编码,它导致:%2520