簡體   English   中英

Chrome擴展程序:yql API錯誤:內容安全

[英]Chrome Extension: yql API ERROR: Content Security

我正在嘗試致電yql api。 但是出現錯誤:我有以下情況

Manfiest.json:
"content_security_policy": "script-src 'self'; object-src 'self'", 

Error:
Refused to load the script 'http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where…withkeys&callback=jQuery20208888747137971222_1400373036635&_=1400373036638' because it violates the following Content Security Policy directive: "script-src 'self' chrome-extension-resource:".'

我嘗試不使用“ content_security_policy”來執行此操作,但仍然會收到錯誤消息。

進行調用的代碼:

yqlAPI = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent(query) + ' &format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=?';

$.getJSON(yqlAPI, function(r){
$.each(r.query.results.li, function(){ 
  if(typeof this.font !== 'undefined')
      {        
        gogoAnime1.push([this.a.href,this.font.content]);

      }
});
gotFollowersOfA(gogoAnime1);});

我一直在尋找CSP( https://developer.chrome.com/extensions/contentSecurityPolicy#relaxing-remote-script ),但是我不明白我必須添加到manifest.json中的內容。 為了使它起作用,所有幫助將不勝感激!

我想知道這是否是因為請求外部對象。

內容安全政策(CSP)-Google Chrome

如果您需要一些外部JavaScript或對象資源 ,則可以通過將應接受腳本的安全來源列入白名單 ,在一定程度上放寬該策略。

因此,請相應調整manfiest.json:

"content_security_policy": 
       "script-src 'self'; object-src 'self' https://query.yahooapis.com/"

而且您需要使用HTTPS來源:

由於中間人攻擊既瑣碎又無法通過HTTP檢測到,因此這些來源將不被接受 目前,我們允許使用以下方案將來源列入白名單: HTTPS,chrome-extension和chrome-extension-resource。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM