在我们的网络应用程序中,我们将CSP设置为仅报告,但是有一天我们会设法阻止它以阻止潜在的恶意内容.我们似乎从iOS 8.2(iPad和iPhone)收到错误的报告,如下所示:
{"csp-report":{"document-uri":"https://one.two.example.edu.us/",
"referrer":"",
"violated-directive":"font-src 'self' *.googleapis.com *.gstatic.com",
"original-policy":"default-src crwebinvoke: crwebinvokeimmediate: crwebnull: 'self' https://localhost:0/chromecheckurl 'self' localhost:* data: wss://localhost:* ws://localhost:* ; script-src 'self' 'unsafe-inline' 'unsafe-eval' *.googleapis.com localhost:*; style-src 'self' 'unsafe-inline' *.googleapis.com code.jquery.com; font-src 'self' *.googleapis.com *.gstatic.com; report-uri /CSP/Report",
"blocked-uri":"null",
"source-file":"https://one.two.example.edu.us/bundles/vender-head?v=0dU-czAflklsV7hMNDvsoTAY6f5NVb4pP01dZ_rIvO81",
"line-number":1}}
Run Code Online (Sandbox Code Playgroud)
document-uri和source-file是完全相同的.所以我无法理解为什么iOS 8.2的移动版Safari会声称这违反了font-src"self",因为它显然是一个自托管文档.
用户似乎都在使用iOS:
Mozilla/5.0 (iPhone; CPU iPhone OS 8_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) CriOS/41.0.2272.58 Mobile/12D508 Safari/600.1.4
Mozilla/5.0 (iPad; CPU OS 8_1_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B440 Safari/600.1.4
Run Code Online (Sandbox Code Playgroud)
有没有人遇到过这个或者找到了解决办法?我担心,如果我武装CSP,它将开始为iOS用户阻止这些字体.
我正在写一个库,我有一个接受字典的方法.字典的值是不受信任/不安全的,但密钥是可信的,如果最终用户能够输入任意密钥名称,则可能发生"坏事".
因此,当其他开发人员使用此库函数时,我想强制他们在编译时知道密钥名称.所以这样的事情是允许的:
string userInput = Console.ReadLine();
Dictionary<string, string> something = new Dictionary<string, string>();
something.Add("MyKey", userInput);
Run Code Online (Sandbox Code Playgroud)
因为"MyKey"是一个字符串文字,在编译时就知道了.但是这样的事情会引发编译或运行时异常:
string userInput = Console.ReadLine();
string userKey = Console.ReadLine();
Dictionary<string, string> something = new Dictionary<string, string>();
something.Add(userKey, userInput);
Run Code Online (Sandbox Code Playgroud)
因为用户输入用于密钥(userKey),因此在编译时它是未知的.
我查看了GetType(),并没有什么能真正区分文字字符串和运行时创建的字符串.
我有两个不同长度的List.我想要实现的是第三个List,其中包含list1中的第一个元素,然后是list2中的第一个元素,然后是list1中的第二个元素,以及list2中的第二个元素,依此类推,直到其中一个元素用尽(它们为止) "不均匀",然后只需添加该列表中的任何剩余项目.
结果应该与list1和list2组合的项目数相同.
我不能使用类似Union.ToList()的东西,因为它没有交织两者,它只是将例如list1中的所有项添加到list2的底部并输出结果.我试过.Zip(Linq)然而,似乎接受了两个元素并将它们合并为一个元素(即将两个字符串连接成一个更长的字符串).
List<string> list1 = new List<string>(){
"4041",
"4040"
};
List<string> list2 = new List<string>(){
"4039",
"4044",
"4075",
"4010",
"4100",
"4070",
"4072"
};
// Ideal result:
result = { "4041",
"4039",
"4040"
"4044",
"4075",
"4010",
"4100",
"4070",
"4072"
};
Run Code Online (Sandbox Code Playgroud) 问题
对于默认路由,MVC返回"找到与名为'admin'的控制器匹配的多个类型." 错误而不是找不到404.该命名空间中没有管理员控制器.
我们正在使用MVC 5.2.2.
背景
我们正在使用MVC领域.两个区域包含"admin"控制器.当您使用各自路径中定义的完整路径时,两个区域的管理控制器都可以访问并正常工作.
当您尝试从默认路由访问"admin"时出现问题.管理员在该上下文中不存在,因此我们期望找不到404,但是我们会收到:
Multiple types were found that match the controller named 'admin'. This can happen
if the route that services this request ('{controller}/{action}/{id}') does not
specify namespaces to search for a controller that matches the request. If this
is the case, register this route by calling an overload of the 'MapRoute' method
that takes a 'namespaces' parameter.
The request for 'admin' has found the following matching controllers:
DMP.Stock.Web.Controllers.AdminController
DMP.Inventory.Web.Controllers.AdminController
Run Code Online (Sandbox Code Playgroud)
这是我们的默认路线和两条区域路线:
public static void RegisterRoutes(RouteCollection …Run Code Online (Sandbox Code Playgroud)