提交 91f2059e 编写于 作者: K Kohsuke Kawaguchi

recognize and properly handle <script src="..."/> injected by the fragment

上级 170a2321
...@@ -453,13 +453,52 @@ function renderOnDemand(e,callback,noBehaviour) { ...@@ -453,13 +453,52 @@ function renderOnDemand(e,callback,noBehaviour) {
} }
Element.remove(e); Element.remove(e);
t.responseText.evalScripts(); evalInnerHtmlScripts(t.responseText,function() {
Behaviour.applySubtree(elements,true); Behaviour.applySubtree(elements,true);
if (callback) callback(t);
});
});
}
if (callback) callback(t); /**
* Finds all the script tags
*/
function evalInnerHtmlScripts(text,callback) {
var q = [];
var matchAll = new RegExp('<script([^>]*)>([\\S\\s]*?)<\/script>', 'img');
var matchOne = new RegExp('<script([^>]*)>([\\S\\s]*?)<\/script>', 'im');
var srcAttr = new RegExp('src=[\'\"]([^\'\"]+)[\'\"]','i');
(text.match(matchAll)||[]).map(function(s) {
var m = s.match(srcAttr);
if (m) {
q.push(function(cont) {
loadScript(m[1],cont);
});
} else {
q.push(function(cont) {
eval(s.match(matchOne)[2]);
cont();
});
}
}); });
q.push(callback);
sequencer(q);
} }
/**
* Take an array of (typically async) functions and run them in a sequence.
* Each of the function in the array takes one 'continuation' parameter, and upon the completion
* of the function it needs to invoke "continuation()" to signal the execution of the next function.
*/
function sequencer(fs) {
var nullFunction = function() {}
function next() {
if (fs.length>0) {
(fs.shift()||nullFunction)(next);
}
}
return next();
}
var hudsonRules = { var hudsonRules = {
"BODY" : function() { "BODY" : function() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册