内容安全策略指令:“script-src 'self' 'unsafe-eval'”

Content Security Policy directive: "script-src 'self' 'unsafe-eval'"

本文关键字:unsafe-eval self script-src 安全策略 指令      更新时间:2023-09-26

我正在使用urlive库通过链接加载缩略图。

在Chrome扩展程序之外,该功能可以完美运行。但是在Chrome扩展程序中运行相同的功能时,我收到错误:

"拒绝加载脚本'http://query.yahooapis.com/v1/public/yql?callback=jQuery1111091462301090359…22+and+xpath%3D%22*%22+and+compat%3D%22html5%22&format=xml&_=1417426473922',因为它违反了以下内容安全策略指令:"script-src 'self' 'unsafe-eval'".

$(document).ready(function() {
  $('#thumbnail_url').on('input propertychange', function () {
    console.log('called');
    $('#thumbnail_url').urlive({
      callbacks: {
        onStart: function () {
          console.log('called1');
          $('.loading').show();
          $('.urlive-container').urlive('remove');
        },
        onSuccess: function (data) {
          $('.loading').hide();
          $('.urlive-container').urlive('remove');
        },
        noData: function () {
          $('.loading').hide();
          $('.urlive-container').urlive('remove');
        }
      }
    });
  }).trigger('input');
});

我已经尝试了所有的可能性。但我没有得到答案。在调用yahooapis时仍然为我引发错误。

如果您正在处理chromeapp,那么请忘记urlive库。"urlive"将采用yahooapis,而yahooapis不适用于构建chrome应用程序。它不断引发错误。所以最好去其他图书馆。

将雅虎域添加到规则中:"script-src 'self' 'unsafe-eval' http://query.yahooapis.com"

有关更多信息:http://content-security-policy.com/