提交 51f508ba 编写于 作者: K Kohsuke Kawaguchi

[FIXED JENKINS-15617]

Evaluate script in global context.
See http://perfectionkills.com/global-eval-what-are-the-options/ for how
to evaluate JavaScript in global context.
上级 11eb4c72
...@@ -364,6 +364,14 @@ function parseHtml(html) { ...@@ -364,6 +364,14 @@ function parseHtml(html) {
return c.firstChild; return c.firstChild;
} }
/**
* Evaluates the script in global context.
*/
function geval(script) {
// see http://perfectionkills.com/global-eval-what-are-the-options/
(this.execScript || eval)(script);
}
/** /**
* Emulate the firing of an event. * Emulate the firing of an event.
* *
...@@ -396,7 +404,7 @@ var tooltip; ...@@ -396,7 +404,7 @@ var tooltip;
function registerValidator(e) { function registerValidator(e) {
e.targetElement = findFollowingTR(e, "validation-error-area").firstChild.nextSibling; e.targetElement = findFollowingTR(e, "validation-error-area").firstChild.nextSibling;
e.targetUrl = function() { e.targetUrl = function() {
return eval(this.getAttribute("checkUrl")); return geval(this.getAttribute("checkUrl"));
}; };
var method = e.getAttribute("checkMethod"); var method = e.getAttribute("checkMethod");
if (!method) method = "get"; if (!method) method = "get";
...@@ -492,7 +500,7 @@ function isInsideRemovable(e) { ...@@ -492,7 +500,7 @@ function isInsideRemovable(e) {
*/ */
function renderOnDemand(e,callback,noBehaviour) { function renderOnDemand(e,callback,noBehaviour) {
if (!e || !Element.hasClassName(e,"render-on-demand")) return; if (!e || !Element.hasClassName(e,"render-on-demand")) return;
var proxy = eval(e.getAttribute("proxy")); var proxy = geval(e.getAttribute("proxy"));
proxy.render(function (t) { proxy.render(function (t) {
var contextTagName = e.parentNode.tagName; var contextTagName = e.parentNode.tagName;
var c; var c;
...@@ -537,7 +545,7 @@ function evalInnerHtmlScripts(text,callback) { ...@@ -537,7 +545,7 @@ function evalInnerHtmlScripts(text,callback) {
}); });
} else { } else {
q.push(function(cont) { q.push(function(cont) {
eval(s.match(matchOne)[2]); geval(s.match(matchOne)[2]);
cont(); cont();
}); });
} }
...@@ -708,7 +716,7 @@ var jenkinsRules = { ...@@ -708,7 +716,7 @@ var jenkinsRules = {
(function() { (function() {
var cmdKeyDown = false; var cmdKeyDown = false;
var mode = e.getAttribute("script-mode") || "text/x-groovy"; var mode = e.getAttribute("script-mode") || "text/x-groovy";
var readOnly = eval(e.getAttribute("script-readOnly")) || false; var readOnly = geval(e.getAttribute("script-readOnly")) || false;
var w = CodeMirror.fromTextArea(e,{ var w = CodeMirror.fromTextArea(e,{
mode: mode, mode: mode,
...@@ -2134,7 +2142,7 @@ function validateButton(checkUrl,paramList,button) { ...@@ -2134,7 +2142,7 @@ function validateButton(checkUrl,paramList,button) {
var s = rsp.getResponseHeader("script"); var s = rsp.getResponseHeader("script");
if(s!=null) if(s!=null)
try { try {
eval(s); geval(s);
} catch(e) { } catch(e) {
window.alert("failed to evaluate "+s+"\n"+e.message); window.alert("failed to evaluate "+s+"\n"+e.message);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册