最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

content security policy - CSP blocks iframe in iframe in firefox - Stack Overflow

programmeradmin2浏览0评论

Consider the following code:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="content-security-policy" content="frame-src 'self';" />
  <title>Outer!</title>
</head>
<body>
  <p>Outer</p>
  <iframe srcdoc="<!DOCTYPE html>
<html lang=&quot;en&quot;>
  <head>
    <meta charset=&quot;UTF-8&quot;>
    <title>Middle in srcdoc</title>
  </head>
  <body>
  <p>Middle</p>
  <iframe src=&quot;inner.html&quot;></iframe>
  </body>
</html>"></iframe>
</body>
</html>

and

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Inner</title>
</head>
<body>Inner</body>
</html>

Set both on the same server, port etc. Now we have an iframe. This contains page via srcdoc, and that one does contain another page via normal src-aatribute. The middle page inherits correctly the CSP from the outer page. In chrome we see all three layers, but in firefox the inner gets blocked by CSP. Apparently it does not know what 'self' is anymore. This seems to be a almost a bug in firefox or at least a strange quirk. Any ideas how to handle this?

发布评论

评论列表(0)

  1. 暂无评论