Skip to content

Commit c1a1197

Browse files
authored
show parameters of a run with readOnlyMode (#10941)
2 parents 79f9ebd + 00770c4 commit c1a1197

File tree

7 files changed

+26
-16
lines changed

7 files changed

+26
-16
lines changed

core/src/main/resources/hudson/model/BooleanParameterValue/value.jelly

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ THE SOFTWARE.
2828
xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
2929
<j:set var="escapeEntryTitleAndDescription" value="false"/>
3030
<f:entry description="${it.formattedDescription}">
31-
<f:checkbox title="${h.escape(it.name)}" name="value" checked="${it.value}" readonly="true" />
31+
<j:set var="readOnlyMode" value="true"/>
32+
<f:checkbox title="${h.escape(it.name)}" name="value" checked="${it.value}"/>
3233
</f:entry>
3334
</j:jelly>

core/src/main/resources/hudson/model/ParametersAction/index.jelly

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ THE SOFTWARE.
3535
<l:main-panel>
3636
<t:buildCaption it="${build}">${title}</t:buildCaption>
3737
<j:set var="escapeEntryTitleAndDescription" value="true" /> <!-- SECURITY-353 defense unless overridden -->
38+
<j:set var="readOnlyMode" value="true"/>
3839
<j:forEach var="parameterValue" items="${it.parameters}">
3940
<st:include it="${parameterValue}" page="value.jelly" />
4041
</j:forEach>

core/src/main/resources/hudson/model/StringParameterValue/value.jelly

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ THE SOFTWARE.
2424

2525
<?jelly escape-by-default='true'?>
2626
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
27-
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"
28-
xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
29-
<j:set var="escapeEntryTitleAndDescription" value="false"/>
30-
<f:entry title="${h.escape(it.name)}" description="${it.formattedDescription}">
31-
<f:textbox name="value" value="${it.value}" readonly="true" />
32-
</f:entry>
27+
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"
28+
xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
29+
<j:set var="escapeEntryTitleAndDescription" value="false"/>
30+
<f:entry title="${h.escape(it.name)}" description="${it.formattedDescription}">
31+
<j:set var="readOnlyMode" value="true"/>
32+
<f:textbox name="value" value="${it.value}"/>
33+
</f:entry>
3334
</j:jelly>

core/src/main/resources/hudson/model/TextParameterValue/value.jelly

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ THE SOFTWARE.
2626
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
2727
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"
2828
xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
29-
<j:set var="escapeEntryTitleAndDescription" value="false"/>
30-
<f:entry title="${h.escape(it.name)}" description="${it.formattedDescription}">
31-
<f:textarea name="value" value="${it.value}" readonly="readonly" />
32-
</f:entry>
29+
<j:set var="escapeEntryTitleAndDescription" value="false"/>
30+
<f:entry title="${h.escape(it.name)}" description="${it.formattedDescription}">
31+
<j:set var="readOnlyMode" value="true"/>
32+
<f:textarea name="value" value="${it.value}"/>
33+
</f:entry>
3334
</j:jelly>

core/src/main/resources/lib/form/checkbox.jelly

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ THE SOFTWARE.
8383
name="${name}"
8484
value="${attrs.value}"
8585
title="${attrs.tooltip}"
86-
onclick="${attrs.readonly=='true' ? 'return false;' : attrs.onclick}" id="${attrs.id}" class="${attrs.class} ${attrs.negative!=null ? 'negative' : null} ${attrs.checkUrl!=null?'validated':''}"
86+
onclick="${attrs.readonly=='true' ? null : attrs.onclick}" id="${attrs.id}" class="${attrs.class} ${attrs.negative!=null ? 'negative' : null} ${attrs.checkUrl!=null?'validated':''}"
8787
checkUrl="${attrs.checkUrl}" checkDependsOn="${attrs.checkDependsOn}" json="${attrs.json}"
88-
disabled="${readOnlyMode ? 'true' : null}"
88+
disabled="${readOnlyMode or attrs.readonly=='true' ? 'true' : null}"
8989
checked="${value ? 'true' : null}"/>
9090
<label class="attach-previous ${attrs.title == null ? 'js-checkbox-label-empty' : ''}"
9191
title="${attrs.tooltip}">${attrs.title}</label>

core/src/main/resources/lib/form/radio.jelly

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ THE SOFTWARE.
2424

2525
<?jelly escape-by-default='true'?>
2626
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define">
27-
<st:documentation> <![CDATA[
27+
<st:documentation> <![CDATA[
2828
<input type="radio"> tag that takes true/false for @checked, which is more Jelly friendly.
2929
3030
Note that Safari doesn't support onchange.
@@ -38,7 +38,13 @@ THE SOFTWARE.
3838
<st:attribute name="checked" />
3939
<st:attribute name="value" />
4040
<st:attribute name="id" />
41-
<st:attribute name="onclick" />
41+
<st:attribute name="onclick" deprecated="true">
42+
Inline JavaScript to execute when the checkbox is clicked.
43+
Deprecated because this attribute is incompatible with adding Content-Security-Policy to the Jenkins UI in the future.
44+
Set 'id' or 'class' attributes as appropriate to look up this element in external Javascript files (e.g. adjuncts)
45+
to add the desired behavior there (DOMContentLoaded event in static forms, Behaviour.specify if this element may be
46+
dynamically added). See https://github.com/jenkinsci/jenkins/pull/6852 for an example.
47+
</st:attribute>
4248
<st:attribute name="title">
4349
If specified, this human readable text will follow the radio, and clicking this text also
4450
toggles the radio.

test/src/test/java/hudson/model/ParametersTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ void xss() throws Exception {
267267
assertAll(
268268
() -> assertThat("parameters page should escape param name", text2, containsString("&lt;param name&gt;")),
269269
() -> assertThat("parameters page should not leave param name unescaped", text2, not(containsString("<param name>"))),
270-
() -> assertThat("parameters page should escape param value", text2, containsString("&lt;param value&gt;")),
270+
() -> assertThat("parameters page should escape param value", text2, containsString("&lt;param value>")),
271271
() -> assertThat("parameters page should not leave param value unescaped", text2, not(containsString("<param value>"))),
272272
() -> assertThat("parameters page should mark up param description", text2, containsString("<b>[</b>param description<b>]</b>")),
273273
() -> assertThat("parameters page should not leave param description unescaped", text2, not(containsString("<param description>")))

0 commit comments

Comments
 (0)