0

我在本地的 9180 端口上有一个测试页面,它正在从另一个端口加载 JS 以模拟不同的域。

<html>
<head>
  <script src="http://localhost:8080/myscript.js" integrity="jRIKARJybgWRWqQslhFC5boBExY7MBLvUpMWYpuXuL1sDqCCp2Gd"></script>
</head>
<body>
  Testing SRI
</body>

myscript.js

alert('Hello');

在浏览器上运行此程序时,我在控制台上看到错误,但仍会触发警报

Error parsing 'integrity' attribute ('jRIKARJybgWRWqQslhFC5boBExY7MBLvUpMWYpuXuL1sDqCCp2Gd'). The hash algorithm must be one of 'sha256', 'sha384', or 'sha512', followed by a '-' character.

我错过了什么吗?或者由于本地浏览器允许执行脚本。

4

1 回答 1

0

由于(如错误消息所述)integrity属性值本身无效,因此浏览器没有强制执行它。

于 2019-03-08T13:40:53.807 回答