Dart &引用;“拒绝加载图像”;在Chrome应用程序中
我在飞镖里有这个问题 拒绝加载图像“https://**.png”,因为它违反了 以下内容安全策略指令:“img src‘self’数据: chrome扩展资源:“ 当尝试在image元素中设置src时Dart &引用;“拒绝加载图像”;在Chrome应用程序中,dart,google-chrome-app,content-security-policy,Dart,Google Chrome App,Content Security Policy,我在飞镖里有这个问题 拒绝加载图像“https://**.png”,因为它违反了 以下内容安全策略指令:“img src‘self’数据: chrome扩展资源:“ 当尝试在image元素中设置src时 ImageButtonInputElement button = new ImageButtonInputElement(); button.className="button_element"; button.src=el["imageUrl"]; //like "https://**.png
ImageButtonInputElement button = new ImageButtonInputElement();
button.className="button_element";
button.src=el["imageUrl"]; //like "https://**.png"
使用此manifest.json
"content_security_policy":"img-src https://server.example.org"
有人会知道帮助我吗
谢谢
对不起,我英语不好
编辑
我也有同样的问题
<iframe id="iframe" src="https://server.example.org/example.html"></iframe>
拒绝诬陷
因为它违反了以下内容安全策略指令:
“帧src‘self’数据:chrome扩展资源:”
应用程序。该清单键仅用于扩展
用于加载要显示的远程内容
同样,你必须在Chrome应用程序中使用iFrame而不是iFrame。这是我最终采用的解决方案:
var imgRequest = new HttpRequest();
imgRequest.open('GET', url);
imgRequest.responseType = 'blob';
imgRequest.onReadyStateChange.listen((var request){
if (imgRequest.readyState == HttpRequest.DONE &&
imgRequest.status == 200) {
FileReader reader = new FileReader();
reader.onLoad.listen((fe) {
button.src = reader.result;
});
reader.readAsDataUrl(imgRequest.response);
}
});
imgRequest.send();
CSP字符串中是否有确切的服务器名称?我的意思是类似于“img src”https://server.example.org“?因为CSP doc说:不允许使用通用通配符,如https:、https://*和https://*.com;允许使用诸如https://*.example.com之类的子域通配符。是的,我使用了(https://**.png)作为示例,但在我的代码中我使用了完整的链接。为了清楚起见,我指的是CSP字符串,而不是您试图加载的图像url。在您的示例中,有
https://
没有任何其他内容,这是不允许的。是的,我使用了类似“内容安全策略”的代码:“img src”。对不起,谢谢!我试着用我采用的解决方案来回答。