Skip to content
Permalink
Browse files

[FIXED JENKINS-16974] Unsafe to define a function in <script> without…

… a generated name, as it could clash with functions defined in unrelated *.jelly that happen to included in the same page.
  • Loading branch information...
jglick committed Jun 11, 2013
1 parent 609c4f8 commit 3c01366e0bc5c3e8de23eb7337e8c3e4dbd7843c
@@ -55,6 +55,9 @@
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=bug>
“Build Now” link did not work for multijobs.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-16974">issue 16974</a>)
<li class=bug>
“Projects tied to slave” shows unrelated Maven module jobs.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-17451">issue 17451</a>)
@@ -45,10 +45,11 @@ THE SOFTWARE.
</l:task>
<j:if test="${it.configurable}">
<j:if test="${it.buildable}">
<j:set var="id" value="${h.generateId()}"/>
<l:task icon="images/24x24/clock.png" href="${url}/build?delay=0sec" title="${it.buildNowText}"
onclick="${it.parameterized?null:'return build(this)'}" post="${!it.parameterized}" permission="${it.BUILD}"/>
onclick="${it.parameterized?null:'return build_' + id + '(this)'}" post="${!it.parameterized}" permission="${it.BUILD}"/>
<script>
function build(a) {
function build_${id}(a) {
new Ajax.Request(a.href);

hoverNotification('${%Build scheduled}',a.parentNode);
@@ -26,6 +26,7 @@ THE SOFTWARE.
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
<td>
<j:if test="${job.buildable and job.hasPermission(job.BUILD)}">
<j:set var="id" value="${h.generateId()}"/>
<a href="${jobBaseUrl}${job.shortUrl}build?delay=0sec">
<j:choose>
<j:when test="${job.parameterized}">
@@ -36,13 +37,13 @@ THE SOFTWARE.
<j:otherwise>
<img src="${imagesURL}/${subIconSize}/clock.png"
title="${%Schedule a build}" alt="${%Schedule a build}"
onclick="return build(this)"
onclick="return build_${id}(this)"
border="0"/>
</j:otherwise>
</j:choose>
</a>
<script>
function build(img) {
function build_${id}(img) {
new Ajax.Request(img.parentNode.href);
hoverNotification('${%Build scheduled}', img, -100);
return false;
@@ -38,9 +38,10 @@ THE SOFTWARE.
A confirmation dialog message.
</st:attribute>
</st:documentation>
<a href="#" onclick="confirmPOST(${post ?: 'false'}, '${attrs.href}', '${h.jsStringEscape(message)}')"><d:invokeBody/></a>
<j:set var="id" value="${h.generateId()}"/>
<a href="#" onclick="confirmPOST_${id}(${post ?: 'false'}, '${attrs.href}', '${h.jsStringEscape(message)}')"><d:invokeBody/></a>
<script>
function confirmPOST(post, href, message) {
function confirmPOST_${id}(post, href, message) {
if (confirm(message)) {
var form = document.createElement('form');
form.setAttribute('method', post ? 'POST' : 'GET');
@@ -115,9 +115,10 @@ THE SOFTWARE.
<j:set var="icon" value="${rootURL}${icon.startsWith('images/') || icon.startsWith('plugin/') ? h.resourcePath : ''}/${icon}"/>
${taskTags!=null and attrs.contextMenu!='false' ? taskTags.add(href, icon, title, post == 'true', requiresConfirmation == 'true') : null}

<j:set var="id" value="${h.generateId()}"/>
<j:if test="${attrs.onclick == null and post and not requiresConfirmation}">
<script>
function postRequest(a) {
function postRequest_${id}(a) {
new Ajax.Request(a.href);
hoverNotification('${%Done.}', a.parentNode);
return false;
@@ -132,7 +133,7 @@ THE SOFTWARE.
</l:confirmationLink>
</j:when>
<j:otherwise>
<a href="${href}" onclick="${attrs.onclick ?: (post ? 'postRequest(this)' : null)}">
<a href="${href}" onclick="${attrs.onclick ?: (post ? 'postRequest_' + id + '(this)' : null)}">
<img width="24" height="24" style="margin: 2px;" alt="" src="${icon}"/>
</a>
</j:otherwise>
@@ -153,7 +154,7 @@ THE SOFTWARE.
</l:confirmationLink>
</j:when>
<j:otherwise>
<a href="${href}" onclick="${attrs.onclick ?: (post ? 'postRequest(this)' : null)}">
<a href="${href}" onclick="${attrs.onclick ?: (post ? 'postRequest_' + id + '(this)' : null)}">
<j:choose>
<j:when test="${match}">
<b>${title}</b>

0 comments on commit 3c01366

Please sign in to comment.
You can’t perform that action at this time.