提交 79384efd 编写于 作者: D Daniel Beck

Merge branch 'stable-2.150' into security-stable-2.150

......@@ -705,13 +705,13 @@ public class CLI implements AutoCloseable {
connection.sendLocale(Locale.getDefault().toString());
connection.sendStart();
connection.begin();
final OutputStream stdin = connection.streamStdin();
new Thread("input reader") {
@Override
public void run() {
try {
final OutputStream stdin = connection.streamStdin();
int c;
while ((c = System.in.read()) != -1) { // TODO use InputStream.available
while (!connection.complete && (c = System.in.read()) != -1) {
stdin.write(c);
}
connection.sendEndStdin();
......
......@@ -1827,7 +1827,7 @@ public class Functions {
* from {@link ConsoleAnnotatorFactory}s and {@link ConsoleAnnotationDescriptor}s.
*/
public static String generateConsoleAnnotationScriptAndStylesheet() {
String cp = Stapler.getCurrentRequest().getContextPath();
String cp = Stapler.getCurrentRequest().getContextPath() + Jenkins.RESOURCE_PATH;
StringBuilder buf = new StringBuilder();
for (ConsoleAnnotatorFactory f : ConsoleAnnotatorFactory.all()) {
String path = cp + "/extensionList/" + ConsoleAnnotatorFactory.class.getName() + "/" + f.getClass().getName();
......
......@@ -255,6 +255,30 @@ public class CLITest {
assertEquals(0, ret);
}
}
@Test
@Issue("JENKINS-54310")
public void readInputAtOnce() throws Exception {
home = tempHome();
grabCliJar();
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();) {
int ret = new Launcher.LocalLauncher(StreamTaskListener.fromStderr())
.launch()
.cmds("java",
"-Duser.home=" + home,
"-jar", jar.getAbsolutePath(),
"-s", r.getURL().toString(),
"list-plugins") // This CLI Command needs -auth option, so when we omit it, the CLI stops before reading the input.
.stdout(baos)
.stderr(baos)
.stdin(CLITest.class.getResourceAsStream("huge-stdin.txt"))
.join();
assertThat(baos.toString(), not(containsString("java.io.IOException: Stream is closed")));
assertEquals(0, ret);
}
}
@TestExtension("redirectToEndpointShouldBeFollowed")
public static final class CliProxyAction extends CrumbExclusion implements UnprotectedRootAction, StaplerProxy {
......
......@@ -3,6 +3,7 @@ package hudson.console;
import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.TextPage;
import com.gargoylesoftware.htmlunit.WebRequest;
import com.gargoylesoftware.htmlunit.html.DomElement;
import com.gargoylesoftware.htmlunit.html.DomNodeUtil;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import hudson.FilePath;
......@@ -27,6 +28,7 @@ import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Future;
import jenkins.model.Jenkins;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.*;
import org.junit.Rule;
......@@ -288,6 +290,12 @@ public class ConsoleAnnotatorTest {
// verify that there's an element inserted by the script
assertNotNull(html.getElementById("inserted-by-test1"));
assertNotNull(html.getElementById("inserted-by-test2"));
for (DomElement e : html.getElementsByTagName("script")) {
String src = e.getAttribute("src");
if (!src.isEmpty()) {
assertThat(src, containsString(Jenkins.SESSION_HASH));
}
}
}
public static final class JustToIncludeScript extends ConsoleNote<Object> {
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册