当用户从 iframe 内部点击覆盖 Chrome 中的新标签页的链接时,缺少"Referer"标题



问题

这是浏览器的预期行为吗?

相关Chromium错误

https://code.google.com/p/chromium/issues/detail?id=492761

步骤

  1. 为Chrome 创建一个空扩展

  2. manifest.json:"chrome_url_overrides": {"newtab": "newtab.html"} 中放入一个新的选项卡覆盖

  3. 创建newtab.html(chrome-extension://<extension_id>/newtab.html(,创建一个iframe并将一些页面加载到其中,例如https://<some_page>.com/

  4. 放置该页面的链接,例如https://example.org/

  5. 单击该链接并观察请求

预期结果

应显示"Referer"标题,例如:

GET / HTTP/1.1
Host: example.org
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.65 Safari/537.36
Referer: https://<some_page>.com/
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8,de;q=0.6,ru;q=0.4
Cookie: ...

实际结果

没有"Referer"标题:

GET / HTTP/1.1
Host: example.org
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.65 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8,de;q=0.6,ru;q=0.4
Cookie: ...

"chrome.org的eroman;把它钉下来(见链接铬错误报告,已经关闭(。

问题是,当iframe包含一个安全的(https(页面,但iframe本身包含在一个不安全的页面中(在本例中被替换为Chrome newtab(时,当用户点击该iframe中的链接时,会发出一个非安全的(http(请求。

RFC 2616第15.1.3节步骤说明:

Clients SHOULD NOT include a Referer header field in a (non-secure)
HTTP request if the referring page was transferred with a secure
protocol.

这使得所描述的情况成为所需的情况,所以浏览器的行为符合标准的预期。

此外,如果链接指向非安全页面,例如。http://example.org/,这将是一个正常的(非安全的(http请求,所以";"裁判";将被省略-只是因为引用页面是安全的。当然,即使没有iframe包装安全页面,这仍然有效。

最新更新