mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-16 05:22:22 +00:00
Avoid double-encoding in option value attribute when populating it from the f:option
body, rather than an explicit value parameter. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@26583 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
bc66945943
commit
af7ffcebf9
2 files changed
+41
-11
No files matched your search
@@ -1,7 +1,7 @@
|
||||
<!--
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
|
||||
Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -38,6 +38,8 @@ THE SOFTWARE.
|
||||
If true, the option value appears as selected.
|
||||
</st:attribute>
|
||||
</st:documentation>
|
||||
<j:set var="optionBody"><d:invokeBody/></j:set>
|
||||
<option value="${attrs.value!=null?attrs.value:optionBody}" selected="${attrs.selected?'true':null}">${optionBody}</option>
|
||||
<!-- No escape/encode to avoid double-encoding if used in value attribute below -->
|
||||
<j:set var="optionBody" encode="false"><d:invokeBody escapeText="false"/></j:set>
|
||||
<option value="${attrs.value!=null?attrs.value:optionBody}"
|
||||
selected="${attrs.selected?'true':null}">${optionBody}</option>
|
||||
</j:jelly>
|
||||
@@ -2,20 +2,19 @@ package hudson.model;
|
||||
|
||||
import org.jvnet.hudson.test.HudsonTestCase;
|
||||
import org.jvnet.hudson.test.CaptureEnvironmentBuilder;
|
||||
import com.gargoylesoftware.htmlunit.Page;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlPage;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlForm;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlElement;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlInput;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlOption;
|
||||
|
||||
/**
|
||||
* @author huybrechts
|
||||
*/
|
||||
public class ParametersTest extends HudsonTestCase {
|
||||
|
||||
public void testStringParameter() throws Exception {
|
||||
public void testParameterTypes() throws Exception {
|
||||
FreeStyleProject otherProject = createFreeStyleProject();
|
||||
otherProject.scheduleBuild2(0).get();
|
||||
|
||||
@@ -31,7 +30,7 @@ public class ParametersTest extends HudsonTestCase {
|
||||
|
||||
WebClient wc = new WebClient();
|
||||
wc.setThrowExceptionOnFailingStatusCode(false);
|
||||
HtmlPage page= wc.goTo("/job/" + project.getName() + "/build?delay=0sec");
|
||||
HtmlPage page = wc.goTo("/job/" + project.getName() + "/build?delay=0sec");
|
||||
|
||||
HtmlForm form = page.getFormByName("parameters");
|
||||
|
||||
@@ -55,8 +54,6 @@ public class ParametersTest extends HudsonTestCase {
|
||||
element = (HtmlElement) form.selectSingleNode(".//tr[td/div/input/@value='choice']");
|
||||
assertNotNull(element);
|
||||
assertEquals("choice description", ((HtmlElement) element.selectSingleNode("td/div")).getAttribute("description"));
|
||||
// HtmlCheckBoxInput booleanParameterInput = (HtmlCheckBoxInput) element.selectSingleNode("//input[@name='value']");
|
||||
// assertEquals(true, booleanParameterInput.isChecked());
|
||||
assertEquals("choice", ((HtmlElement) element.selectSingleNode("td[@class='setting-name']")).getTextContent());
|
||||
|
||||
element = (HtmlElement) form.selectSingleNode(".//tr[td/div/input/@value='run']");
|
||||
@@ -65,8 +62,9 @@ public class ParametersTest extends HudsonTestCase {
|
||||
assertEquals("run", ((HtmlElement) element.selectSingleNode("td[@class='setting-name']")).getTextContent());
|
||||
|
||||
submit(form);
|
||||
|
||||
Thread.sleep(1000);
|
||||
Queue.Item q = hudson.getQueue().getItem(project);
|
||||
if (q != null) q.getFuture().get();
|
||||
else Thread.sleep(1000);
|
||||
|
||||
assertEquals("newValue", builder.getEnvVars().get("STRING"));
|
||||
assertEquals("true", builder.getEnvVars().get("BOOLEAN"));
|
||||
@@ -74,4 +72,34 @@ public class ParametersTest extends HudsonTestCase {
|
||||
assertEquals(hudson.getRootUrl() + otherProject.getLastBuild().getUrl(), builder.getEnvVars().get("RUN"));
|
||||
}
|
||||
|
||||
public void testChoiceWithLTGT() throws Exception {
|
||||
FreeStyleProject project = createFreeStyleProject();
|
||||
ParametersDefinitionProperty pdp = new ParametersDefinitionProperty(
|
||||
new ChoiceParameterDefinition("choice", "Choice 1\nChoice <2>", "choice description"));
|
||||
project.addProperty(pdp);
|
||||
CaptureEnvironmentBuilder builder = new CaptureEnvironmentBuilder();
|
||||
project.getBuildersList().add(builder);
|
||||
|
||||
WebClient wc = new WebClient();
|
||||
wc.setThrowExceptionOnFailingStatusCode(false);
|
||||
HtmlPage page = wc.goTo("/job/" + project.getName() + "/build?delay=0sec");
|
||||
HtmlForm form = page.getFormByName("parameters");
|
||||
|
||||
HtmlElement element = (HtmlElement) form.selectSingleNode(".//tr[td/div/input/@value='choice']");
|
||||
assertNotNull(element);
|
||||
assertEquals("choice description", ((HtmlElement) element.selectSingleNode("td/div")).getAttribute("description"));
|
||||
assertEquals("choice", ((HtmlElement) element.selectSingleNode("td[@class='setting-name']")).getTextContent());
|
||||
HtmlOption opt = (HtmlOption)element.selectSingleNode("td/div/select/option[@value='Choice <2>']");
|
||||
assertNotNull(opt);
|
||||
assertEquals("Choice <2>", opt.asText());
|
||||
opt.setSelected(true);
|
||||
|
||||
submit(form);
|
||||
Queue.Item q = hudson.getQueue().getItem(project);
|
||||
if (q != null) q.getFuture().get();
|
||||
else Thread.sleep(1000);
|
||||
|
||||
assertNotNull(builder.getEnvVars());
|
||||
assertEquals("Choice <2>", builder.getEnvVars().get("CHOICE"));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user