diff --git a/src/main/java/com/cloudbees/jenkins/support/impl/UpdateCenter.java b/src/main/java/com/cloudbees/jenkins/support/impl/UpdateCenter.java index a1c2db93..907f1843 100644 --- a/src/main/java/com/cloudbees/jenkins/support/impl/UpdateCenter.java +++ b/src/main/java/com/cloudbees/jenkins/support/impl/UpdateCenter.java @@ -4,6 +4,7 @@ import com.cloudbees.jenkins.support.api.Container; import com.cloudbees.jenkins.support.api.PrefilteredPrintedContent; import com.cloudbees.jenkins.support.filter.ContentFilter; +import com.cloudbees.jenkins.support.util.Markdown; import edu.umd.cs.findbugs.annotations.NonNull; import hudson.Extension; import hudson.ProxyConfiguration; @@ -72,13 +73,14 @@ private void addProxyInformation(PrintWriter out, ContentFilter filter) { out.println("=== Proxy ==="); ProxyConfiguration proxy = Jenkins.get().getProxy(); if (proxy != null) { - out.println(" - Host: " + ContentFilter.filter(filter, proxy.getName())); + out.println(" - Host: `" + Markdown.escapeBacktick(ContentFilter.filter(filter, proxy.getName())) + "`"); out.println(" - Port: " + proxy.getPort()); out.println(" - No Proxy Hosts: "); String noProxyHostsString = proxy.getNoProxyHost(); if (noProxyHostsString != null) { Arrays.stream(noProxyHostsString.split("[ \t\n,|]+")) - .forEach(noProxyHost -> out.println(" * " + ContentFilter.filter(filter, noProxyHost))); + .forEach(noProxyHost -> out.println( + " * `" + Markdown.escapeBacktick(ContentFilter.filter(filter, noProxyHost)) + "`")); } } } diff --git a/src/test/java/com/cloudbees/jenkins/support/impl/UpdateCenterTest.java b/src/test/java/com/cloudbees/jenkins/support/impl/UpdateCenterTest.java index 379981a1..776a5b3b 100644 --- a/src/test/java/com/cloudbees/jenkins/support/impl/UpdateCenterTest.java +++ b/src/test/java/com/cloudbees/jenkins/support/impl/UpdateCenterTest.java @@ -26,24 +26,22 @@ public class UpdateCenterTest { public void testUpdateCenterProxyContent() { List noProxyHosts = Arrays.asList(".server.com", "*.example.com"); - j.jenkins - .get() - .setProxy(new ProxyConfiguration( - "proxy.server.com", - 1234, - "proxyUser", - "proxyPass", - String.join("\n", noProxyHosts), - "http://localhost:8080")); + j.jenkins.setProxy(new ProxyConfiguration( + "proxy.server.com", + 1234, + "proxyUser", + "proxyPass", + String.join("\n", noProxyHosts), + "http://localhost:8080")); String ucMdToString = SupportTestUtils.invokeComponentToString( Objects.requireNonNull(ExtensionList.lookup(Component.class).get(UpdateCenter.class))); - assertThat(ucMdToString, containsString(" - Host: proxy.server.com")); + assertThat(ucMdToString, containsString(" - Host: `proxy.server.com`")); assertThat(ucMdToString, containsString(" - Port: 1234")); assertThat(ucMdToString, not(containsString("proxyUser"))); assertThat(ucMdToString, not(containsString("proxyPass"))); for (String noProxyHost : noProxyHosts) { - assertThat(ucMdToString, containsString(" * " + noProxyHost)); + assertThat(ucMdToString, containsString(" * `" + noProxyHost + "`")); } } }