-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove the inline javascript from the redirect page and the index of the action. use relative urls in the redirect instead of absoluturl which is considered dangerous (this probably fixes JENKINS-64825)
- Loading branch information
1 parent
4c3a721
commit d18e6b2
Showing
5 changed files
with
28 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Behaviour.specify("#schedule-build-input", "schedule-build-input", 0, function(input) { | ||
input.onkeyup = function(event) { | ||
input.onchange(); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,14 @@ | ||
var newRequest = function() { | ||
if (window.XMLHttpRequest) { | ||
return new XMLHttpRequest(); | ||
} else { | ||
return new ActiveXObject("Microsoft.XMLHTTP"); | ||
} | ||
} | ||
|
||
var sumbitScheduleRequest = function(absoluteUrl, quietPeriodInSeconds, isJobParameterized){ | ||
|
||
if(isJobParameterized){ | ||
// if job has parameters, redirect to build page, so user can set parameters | ||
window.location = absoluteUrl + "build?delay=" + quietPeriodInSeconds + "sec"; | ||
}else{ | ||
// if job has NO parameters, submit build directly | ||
var csrfCrumb; | ||
var csrfRequest = newRequest(); | ||
csrfRequest.onreadystatechange = function() { | ||
if (csrfRequest.readyState === 4) { | ||
if (csrfRequest.status === 200 || csrfRequest.status === 201) { | ||
csrfCrumb = JSON.parse(csrfRequest.responseText); | ||
} else { | ||
// csrf might be deactivated | ||
} | ||
|
||
// do the actual submit | ||
var xmlhttp = newRequest(); | ||
xmlhttp.onreadystatechange = function() { | ||
if (xmlhttp.readyState === 4) { | ||
if (xmlhttp.status === 200 || xmlhttp.status === 201) { | ||
window.location = absoluteUrl; | ||
return false; | ||
} else { | ||
window.location = absoluteUrl; | ||
return false; | ||
} | ||
} | ||
}; | ||
xmlhttp.open("POST", absoluteUrl + "build?delay=" + quietPeriodInSeconds + "sec", true); | ||
if (csrfCrumb) { | ||
xmlhttp.setRequestHeader(csrfCrumb.crumbRequestField, csrfCrumb.crumb) | ||
} | ||
xmlhttp.send(); | ||
} | ||
}; | ||
|
||
csrfRequest.open('GET', rootURL + '/crumbIssuer/api/json', false); | ||
csrfRequest.send(); | ||
} | ||
let d = document.getElementById("schedule-build-data"); | ||
let url = d.dataset.url; | ||
let quietPeriodInSeconds = d.dataset.quietPeriodSeconds; | ||
let scheduleUrl = url + "build?delay=" + quietPeriodInSeconds + "sec"; | ||
|
||
if (d.dataset.parameterized === "true") { | ||
window.location = d.dataset.url + "build?delay=" + quietPeriodInSeconds + "sec"; | ||
} else { | ||
fetch(scheduleUrl, { | ||
method: "post", | ||
headers: crumb.wrap({}), | ||
}); | ||
window.location = url; | ||
} |