长话短说:仅在 Chrome 和 Safari 上,登录表单中的值有时会粘贴到用户的 URL 中,即使实际登录是通过 AJAX 发布的。
http://my-site.example/?name=user&pw=xxx&challenge=b1be8ad7aac242...
它被反复报道,我亲眼目睹了它的发生,但我自己无法重现它,更不用说弄清楚到底发生了什么。以下是登录表单归结为:
<form name="login">
<input type="Text" name="name">
<input type="password" name="pw">
<input type="hidden" name="challenge">
<input type="button" onclick='JavaScript:xmlhttpPost("/php/login.php")'>
</form>
实际的 POSTed 请求甚至不包含挑战参数:
function xmlhttpPost(strURL) {
if (window.XMLHttpRequest) {
self.xmlHttpReq = new XMLHttpRequest();
} else if (window.ActiveXObject) {
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
self.xmlHttpReq.open('POST', strURL, true);
...
query = 'name=' + encodeURIComponent(name) + '&pw=' + encodeURIComponent(hash) + '&lpw=' + encodeURIComponent(legacy_hash);
self.xmlHttpReq.send(query);
}
并且在成功登录时,当且仅当用户的语言设置与默认设置不同时,用户才会被重定向回同一页面(= 强制重新加载):
location.href = "http://" + location.host + location.pathname;
有任何想法吗?