gpt4 book ai didi

javascript - 在 Firefox OS 验证器中检测到 CSP 违规

转载 作者:行者123 更新时间:2023-11-30 12:55:46 25 4
gpt4 key购买 nike

我在 firefox os 验证器中有这条消息:

Erreur:您的代码似乎正在执行违反特权应用程序 CSP(内容安全策略)的操作。您可以在 Mozilla 开发者网站上找到有关 CSP 允许和不允许的内容的更多信息。 https://developer.mozilla.org/en-US/docs/Security/CSP

www/index.html
16
17
<script type="text/javascript" src="js/select2.js"></script>
<script>

代码index.html:

<!DOCTYPE html> 
<html>
<head>
<title>Chri App</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="js/jquery.css.min.css" rel="stylesheet"/>
<script src="js/jquery-1.9.1.min.js"></script>
<script src="js/jquery.mobile-1.3.1.min.js"></script>
<meta charset='utf-8'>
<meta name="format-detection" content="telephone=no" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="js/select2/select2.css" rel="stylesheet" >
<link href="css/web_app.css" rel="stylesheet" >
<script src="main.js"></script>
<script type="text/javascript" src="js/select2/select2.js"></script>
<script>

$(document).bind('pageinit',function(e ){


$.support.cors = true;
$.mobile.allowCrossDomainPages= true;
$.mobile.selectmenu.prototype.options.nativeMenu = false;





// When the testform is submitted
$("#search-form-location").select2();
$("#search-form-category").select2();
$("#testform").submit(function() {

$.mobile.loading('show');
.......

你有想法吗?

最佳答案

如果您正在编写特权(或认证)应用程序,它需要符合多项要求,以使其更健壮 - 不易受到各种攻击。限制之一禁止内联 javascript,即嵌入在 <script> 中的 javascript标签 - 您应该将这些内联脚本放入外部 .js文件,并通过 src 链接它们属性。

查看您的代码,这应该是验证器提示的原因(请参阅此处的 jQuery $(document).bind(... block )。将此 block 放入外部文件应该可以解决此问题。

您可以在 MDN: Apps CSP 上阅读更多关于其他 CSP 要求和限制的信息.

关于javascript - 在 Firefox OS 验证器中检测到 CSP 违规,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19209134/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com