12

मैं रुपये पाठक के लिए क्रोम एक्सटेंशन बना रहा हूं जिसमें मुझे उपरोक्त त्रुटि मिल रही है। कृपया jquery.min.js मेंइनलाइन स्क्रिप्ट निष्पादित करने से इंकार कर दिया क्योंकि यह निम्न सामग्री सुरक्षा नीति निर्देश का उल्लंघन करता है: "script-src 'self'"

{ 
    "name": "Tutorialzine Extension", 
     "manifest_version": 2, 
     "version": "1.1", 
     "description": "Making your first Google Chrome extension.", 
     "icons": { 
     "128": "icon_128.png" 
    }, 
     "web_accessible_resources": ["script.js", "https://query.yahooapis.com"], 
     "browser_action": { 
     "default_icon": "icon.png", 
      "default_popup": "tutorialzine.html" 
    }, 
     "permissions": ["tabs", "<all_urls", "http://localhost/", 
     "http://*/*", "https://*/*", "https://query.yahooapis.com"], 
     "content_security_policy": "script-src 'self'; 'https://query.yahooapis.com';unsafe-inline; object-src 'self'" 
} 

script.js

$(document).ready(function() { 

    var query = "SELECT * FROM feed WHERE url='http://feeds.feedburner.com/Tutorialzine' LIMIT 2"; 

    // Storing the seconds since the epoch in now: 
    var now = (new Date()).getTime()/1000; 

    // If there is no cache set in localStorage, or the cache is older than 1 hour: 
    if (!localStorage.cache || now - parseInt(localStorage.time) > 1 * 60 * 60) { 
     $.get("yahoo.js", function (msg) { 

      // msg.query.results.item is an array: 
      var items = msg.query.results.item; 
      var htmlString = ""; 

      for (var i = 0; i < items.length; i++) { 
       var tut = items[i]; 

       // Extracting the post ID from the permalink: 
       var id = tut.guid.content.match(/(\d+)$/)[0]; 

       // Looping and generating the markup of the tutorials: 

       htmlString += '<div class="tutorial">\ 
          <img src="http://tutorialzine.com/img/posts/' + id + '.jpg" />\ 
          <h2>' + tut.title + '</h2>\ 
          <p>' + tut.description + '</p>\ 
          <a href="' + tut.link + '" target="_blank">Read more</a>\ 
          </div>'; 
      } 

      // Setting the cache 
      localStorage.cache = htmlString; 
      localStorage.time = now; 

      // Updating the content div: 
      $('#content').html(htmlString); 
     }, 'json'); 
    } else { 
     // The cache is fresh, use it: 
     $('#content').html(localStorage.cache); 
    } 
} 

त्रुटि मदद

manifest.json:

Jquery.min.js इनलाइन स्क्रिप्ट शामिल

क्या करना है
parentNode:d.removeChild(d.appendChild(s.createElement("div"))).parentNode===null,deleteExpando:true,checkClone:false,scriptEval:false,noCloneEvent:true,boxModel:null};b.type="text/javascript";try{b.appendChild(s.createTextNode("window."+f+"=1;"))}catch(i){}a.insertBefore(b,a.firstChild);if(A[f]){c.support.scriptEval=true;delete A[f]}try{delete b.test}catch(o){c.support.deleteExpando=false}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function k(){c.support.noCloneEvent= 
+1

आप stackoverflow मार्कअप बनाने के लिए कोशिश कर सकते समस्या पार्सर खुश, यानी कोड के सामने 4 रिक्त स्थान जोड़ें (ऐसा करने के लिए टूलबार बटन मौजूद है)। – mnagel

+3

आपके सीएसपी में कुछ त्रुटियां हैं। इसे पढ़ना चाहिए: '' script-src 'self' https://query.yahooapis.com; ऑब्जेक्ट-src 'self' "'। 'Web_accessible_resources' में' https: // query.yahooapis.com' भी आवश्यक नहीं है; वह सरणी स्थानीय रूप से होस्ट किए गए एक्सटेंशन संसाधनों के लिए है, जिन्हें आप नियमित, गैर-विस्तारित वेबपृष्ठों पर उपलब्ध करा सकते हैं। – apsillers

+0

को Google-क्रोम-ऐप टैग नहीं किया जाना चाहिए, क्योंकि ऐप्स और एक्सटेंशन के बीच सीएसपी समस्याएं अलग-अलग हैं। –

उत्तर

5

LinkedIn oAuth API के साथ काम करते समय मुझे इस तरह की समस्या का भी सामना करना पड़ा।

मैं कॉर्डोबा

config.xml

<access origin="*" launch-external="yes"/> 
    <allow-navigation href="*" /> 

मेटा टैग था

<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'"> 

स्क्रिप्ट

के लिए निम्न सेटिंग के साथ लिंक्डइन एपीआई का उपयोग कर रहा था
<script type="text/javascript" src="http://platform.linkedin.com/in.js"></script> 

जब मैं एमुलेटर पर एप्लिकेशन को चलाने के अपने दे

enter image description here

फिक्स्ड uri मेटा टैग http://platform.linkedin.com में जोड़ने के लिए की तरह

<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval' http://platform.linkedin.com "> 
+1

असुरक्षित-असफल और असुरक्षित इनलाइन का उपयोग करके दिमाग में एक सुरक्षा जोखिम है। आप बस 'स्वयं' और 'असुरक्षित-इनलाइन' का उपयोग कर ठीक हो सकते हैं। –

संबंधित मुद्दे

 संबंधित मुद्दे