我在網頁視圖使用它加載從Android應用程序的資產腳本的iframe如下: -如何將CSP限制爲file:/// url in chrome?
<script src='file:///android_asset/trusted-iframe-script.js'></script>
現在我想對IFRAME內容的安全策略,使得沒有其他的腳本可以被加載。 爲此,我增加了以下內容的iframe CSP
script-src: 'file:///android_asset/trusted-iframe-script.js';
因爲文件URI由鉻忽略這不起作用。
The source list for Content Security Policy directive 'script-src' contains an invalid source: 'file:///android_asset/trusted-iframe-script.js'. It will be ignored.
Refused to load the script 'file:///android_asset/trusted-iframe-script.js' because it violates the following Content Security Policy directive: "script-src file:///android_asset/trusted-iframe-script.js".
我讀到關於文件系統的URI,但需要請求訪問用戶,但我實際上只需要訪問自己的資產,不是一般的文件系統。我還讀到blob:urls,但感覺類似於內聯整個腳本
什麼是正確的方式來限制只有文件的URL?