3

사용자 지정 RSS 피드를 표시하려고하지만 피드가 가져올 수없는 크롬 응용 프로그램을 개발하려고합니다. 위의 같은로드와 dispalying 오류입니다. 표시다음 내용 보안 정책 지시문을 위반하여 스크립트를로드하지 못했습니다. "script-src 'self'

오류 세부하는

Refused to load the script 
'https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js' 
because it violates the following Content Security Policy directive: 
"script-src 'self' 
https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js". 

    Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' 
https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js". 
jquery.min.js:35 

    Refused to load the script 'https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js' 
because it violates the following Content Security Policy directive: 
"script-src 'self' 
https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js". 

    Refused to load the script 'http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=2&output=json&q=http%3A%2F%2Fblog.tax2290.com%2Ffeed%2F&hl=en&callback=jsonp1373953012503' 
because it violates the following Content Security Policy directive: 
"script-src 'self' 
https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js". 

manifest.json을

당신이 패키지 응용 프로그램을 빌드하는 경우
{ 
     "name": "Tax New 2290", 
     "manifest_version": 2, 
     "version": "1.1", 
     "description": "Tax 2290", 
    "web_accessible_resources": ["images/logo.png"], 
     "icons": { 
     "16": "icon16.png", 
     "19":"icon19.png", 
     "48": "icon48.png", 
     "128": "icon128.png", 
     "256": "icon256.png" 
    }, 
    "browser_action": 
    { 
    "default_icon":"images/logo.png", 
    "default_popup":"index.html" 
    }, 

     "permissions": ["tabs", "<all_urls>","http://www.tax2290.com","http://*/*", "https://*/*","http://*.google.com/"], 
     "content_security_policy": "script-src 'self' https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js; https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js; object-src 'self'" 

    } 

index.html을

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script> 
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="images/feed.js"></script> 
<link rel="stylesheet" href="images/style.css" type="text/css" /> 
<title>Chrome Popup</title> 
</head> 

feed.js

 $(function() { 
       var $items = $('#vtab>ul>li'); 
       $items.mouseover(function() { 
        $items.removeClass('selected'); 
        $(this).addClass('selected'); 

        var index = $items.index($(this)); 
        $('#vtab>div').hide().eq(index).show(); 
       }).eq(0).mouseover(); 
      }); 


    $(document).ready(function() { 
     $('#divRss2').FeedEk({ 
      FeedUrl: 'http://blog.tax2290.com/feed/', 
      MaxCount: 2,ShowDesc: true, 
      ShowPubDate: true, 
      DescCharacterLimit: 250 
     }); 
    }); 


    > Please tel me how could avoid these errors and load the custom RSS feeds. 
+1

[스크립트 - src '자체' "] (http://stackoverflow.com/questions/17653384/refused-to-execute-content/)에 위배되기 때문에 인라인 스크립트를 실행할 수 없습니다. 인라인 스크립트 위반으로 인해 콘텐츠 보안 위반) –

+0

Chrome 앱, Chrome 확장 프로그램, 호스팅 된 앱 및 기존 패키지 앱과 같이 manifest.json 파일을 포함 할 수있는 Chrome 항목이 4 개 있습니다. 이 네 가지 중 어느 것을 작성하려고하는지 정확하게 파악할 수 있다면 도움이 될 것입니다. 귀하의 질문에 "크롬 응용 프로그램"에 대한 언급이 있지만 표시되는 목록은 Chrome 응용 프로그램에 대한 것이 아니므로 현재 수행하려는 작업이 명확하지 않습니다. –

답변

1

, 당신은 외부 스크립트를로드 할 수 없습니다. 응용 프로그램에는 모든 스크립트, 스타일 또는 이미지가 포함되어야합니다.

확인 당신이 크롬 응용 프로그램 CSP 규칙을 따르고 있습니다 보장하기 위해이 링크 : https://developer.chrome.com/extensions/contentSecurityPolicy

+1

패키지 된 앱에 대해 이야기하고 있습니다 (질문은 분명 앱에 관한 것이 아닙니다). 확장 프로그램은 외부 스크립트를로드 할 수 있습니다. – Xan

1

귀하의 "content_security_policy는"몇 가지 문제가있다.

1) 먼저 1.4.1 및 1.9.1 jquery 선언 사이의 세미콜론을 제거해야합니다. 여러 개의 URL은 하나의 공백으로 분리해야하며 다른 문자는 분리하지 않아야합니다.

2) 두 번째는이 스크립트 "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=2&output=json&q=http%3A%2F%2Fblog.tax2290.com%2Ffeed%2F&hl=en&callback=jsonp1373953012503"을로드하려고하지만 CSP에서는 허용하지 않는 것입니다.

3) 셋째, 인라인 스크립트를 허용해야합니다.

I는 다음과 같이 당신의 "content_security_policy"로 변경합니다 :

"content_security_policy": "script-src 'self' https://ajax.googleapis.com/ 'unsafe-inline'; object-src 'self'" 

'안전하지 않은 인라인'을 "인라인 스크립트를 실행 거부"오류를 수정해야합니다.

https://ajax.googleapis.com/은 jquery와/ajarx/services/feed/load URL을 모두로드 할 수 있어야합니다.

+3

Chrome 확장 프로그램에서 Downvote :'unsafe-inline'이 무시됩니다. – Xan

관련 문제