diff --git a/lib/ace/mode/javascript/jshint.js b/lib/ace/mode/javascript/jshint.js index 6c6054618e8..adc51597e48 100644 --- a/lib/ace/mode/javascript/jshint.js +++ b/lib/ace/mode/javascript/jshint.js @@ -3265,68 +3265,7 @@ module.exports = slice; // and correctly escapes quotes within interpolated code. // NB: `oldSettings` only exists for backwards compatibility. function template(text, settings, oldSettings) { - if (!settings && oldSettings) settings = oldSettings; - settings = defaults({}, settings, _$1.templateSettings); - - // Combine delimiters into one regular expression via alternation. - var matcher = RegExp([ - (settings.escape || noMatch).source, - (settings.interpolate || noMatch).source, - (settings.evaluate || noMatch).source - ].join('|') + '|$', 'g'); - - // Compile the template source, escaping string literals appropriately. - var index = 0; - var source = "__p+='"; - text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { - source += text.slice(index, offset).replace(escapeRegExp, escapeChar); - index = offset + match.length; - - if (escape) { - source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; - } else if (interpolate) { - source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; - } else if (evaluate) { - source += "';\n" + evaluate + "\n__p+='"; - } - - // Adobe VMs need the match returned to produce the correct offset. - return match; - }); - source += "';\n"; - - var argument = settings.variable; - if (argument) { - // Insure against third-party code injection. (CVE-2021-23358) - if (!bareIdentifier.test(argument)) throw new Error( - 'variable is not a bare identifier: ' + argument - ); - } else { - // If a variable is not specified, place data values in local scope. - source = 'with(obj||{}){\n' + source + '}\n'; - argument = 'obj'; - } - - source = "var __t,__p='',__j=Array.prototype.join," + - "print=function(){__p+=__j.call(arguments,'');};\n" + - source + 'return __p;\n'; - - var render; - try { - render = new Function(argument, '_', source); - } catch (e) { - e.source = source; - throw e; - } - - var template = function(data) { - return render.call(this, data, _$1); - }; - - // Provide the compiled source as a convenience for precompilation. - template.source = 'function(' + argument + '){\n' + source + '}'; - - return template; + console.error("should not happen"); } // Traverses the children of `obj` along `path`. If a child is a function, it diff --git a/lib/ace/mode/yaml/yaml-lint.js b/lib/ace/mode/yaml/yaml-lint.js index 6c7afaad6f3..2969341435e 100644 --- a/lib/ace/mode/yaml/yaml-lint.js +++ b/lib/ace/mode/yaml/yaml-lint.js @@ -3500,37 +3500,7 @@ function resolveJavascriptFunction(data) { } function constructJavascriptFunction(data) { - /*jslint evil:true*/ - - var source = '(' + data + ')', - ast = esprima.parse(source, { range: true }), - params = [], - body; - - if (ast.type !== 'Program' || - ast.body.length !== 1 || - ast.body[0].type !== 'ExpressionStatement' || - (ast.body[0].expression.type !== 'ArrowFunctionExpression' && - ast.body[0].expression.type !== 'FunctionExpression')) { - throw new Error('Failed to resolve function'); - } - - ast.body[0].expression.params.forEach(function (param) { - params.push(param.name); - }); - - body = ast.body[0].expression.body.range; - - // Esprima's ranges include the first '{' and the last '}' characters on - // function expressions. So cut them out. - if (ast.body[0].expression.body.type === 'BlockStatement') { - /*eslint-disable no-new-func*/ - return new Function(params, source.slice(body[0] + 1, body[1] - 1)); - } - // ES6 arrow functions can omit the BlockStatement. In that case, just return - // the body. - /*eslint-disable no-new-func*/ - return new Function(params, 'return ' + source.slice(body[0], body[1])); + return function() {} } function representJavascriptFunction(object /*, style*/) { diff --git a/src/ext/modelist.js b/src/ext/modelist.js index 07092bb1405..89b03632b2c 100644 --- a/src/ext/modelist.js +++ b/src/ext/modelist.js @@ -40,7 +40,7 @@ class Mode { }) + "$"; } else { - re = "^.*\\.(" + extensions + ")$"; + re = "\\.(" + extensions + ")$"; } this.extRe = new RegExp(re, "gi"); diff --git a/src/mode/_test/highlight_rules_test.js b/src/mode/_test/highlight_rules_test.js index a2f84d80326..e0db6898877 100644 --- a/src/mode/_test/highlight_rules_test.js +++ b/src/mode/_test/highlight_rules_test.js @@ -329,6 +329,7 @@ function checkBacktracking(tokenizer) { var regex = rule.regex; if (regex && typeof regex != "string") regex = regex.source; if (!regex) return; + regex = "(" + regex + ")|"; var result = require("recheck").checkSync(regex, "gmi", { checker: "automaton", timeout: 100000