Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/383.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript SonarQube-不应使用函数构造函数_Javascript_Sonarqube_Ecmascript 5 - Fatal编程技术网

Javascript SonarQube-不应使用函数构造函数

Javascript SonarQube-不应使用函数构造函数,javascript,sonarqube,ecmascript-5,Javascript,Sonarqube,Ecmascript 5,我正在使用SonarQube扫描ASP.NET MVC项目进行代码质量检查。SonarQube显示项目中使用的某个javascript库的漏洞错误i.e-datepicker.js 错误- 检查此“函数”调用并确保其参数已正确验证。 下面是datepicker.js中的代码- (function(){ var cache = {}; this.tmpl = function tmpl(str, data){ // Figure out if we're getting a t

我正在使用SonarQube扫描ASP.NET MVC项目进行代码质量检查。SonarQube显示项目中使用的某个javascript库的漏洞错误i.e-datepicker.js

错误- 检查此“函数”调用并确保其参数已正确验证。

下面是datepicker.js中的代码-

(function(){
  var cache = {};
 
  this.tmpl = function tmpl(str, data){
    // Figure out if we're getting a template, or if we need to
    // load the template - and be sure to cache the result.
    var fn = !/\W/.test(str) ?
      cache[str] = cache[str] ||
        tmpl(document.getElementById(str).innerHTML) :
     
      // Generate a reusable function that will serve as a template
      // generator (and which will be cached).
      new Function("obj",
        "var p=[],print=function(){p.push.apply(p,arguments);};" +
       
        // Introduce the data as local variables using with(){}
        "with(obj){p.push('" +
       
        // Convert the template into pure JavaScript
        str
          .replace(/[\r\t\n]/g, " ")
          .split("<%").join("\t")
          .replace(/((^|%>)[^\t]*)'/g, "$1\r")
          .replace(/\t=(.*?)%>/g, "',$1,'")
          .split("\t").join("');")
          .split("%>").join("p.push('")
          .split("\r").join("\\'")
      + "');}return p.join('');");
   
    // Provide some basic currying to the user
    return data ? fn( data ) : fn;
  };
})
解决方案-它还提供了解决方案。它说,您应该使用ECMAScript 5的内置JSON函数或专用库

链接-


可以使用哪些替代方案来代替新功能(“param1”、“param2”)来通过声纳扫描?

Urgh,
with
语句。。。使用另一个库。您正在扫描第三方库吗?第三方库很少,但我在这方面面临问题。我是你的工具。
new Function("obj",
            "var p=[],print=function(){p.push.apply(p,arguments);};" +
           
            // Introduce the data as local variables using with(){}