diff --git a/core/src/main/java/hudson/console/HyperlinkNote.java b/core/src/main/java/hudson/console/HyperlinkNote.java
index 8d0e13d70bada17908d4ee72083858430b3e8676..a5bf663d9ad7e58af12e8f38564e367a6308acbf 100644
--- a/core/src/main/java/hudson/console/HyperlinkNote.java
+++ b/core/src/main/java/hudson/console/HyperlinkNote.java
@@ -25,6 +25,7 @@ package hudson.console;
import hudson.Extension;
import hudson.MarkupText;
+import hudson.Util;
import jenkins.model.Jenkins;
import org.jenkinsci.Symbol;
import org.kohsuke.accmod.Restricted;
@@ -69,7 +70,7 @@ public class HyperlinkNote extends ConsoleNote {
url = Jenkins.get().getRootUrl()+url.substring(1);
}
}
- text.addMarkup(charPos, charPos + length, "", "");
+ text.addMarkup(charPos, charPos + length, "", "");
return null;
}
diff --git a/test/src/test/java/hudson/console/HyperlinkNoteTest.java b/test/src/test/java/hudson/console/HyperlinkNoteTest.java
index c65019f29290d84231e0b6a7312ca62c20a6347f..5f56f4524a1d9e92c58d74cebe44bf873715f686 100644
--- a/test/src/test/java/hudson/console/HyperlinkNoteTest.java
+++ b/test/src/test/java/hudson/console/HyperlinkNoteTest.java
@@ -24,11 +24,16 @@
package hudson.console;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
+
+import hudson.model.Result;
+import hudson.tasks.BuildTrigger;
import org.apache.commons.io.IOUtils;
import org.junit.Rule;
import org.junit.Test;
@@ -73,6 +78,19 @@ public class HyperlinkNoteTest {
containsString(">" + noteTextSanitized + "")));
}
+ @Test
+ public void textWithSingleQuote() throws Exception {
+ FreeStyleProject upstream = r.createFreeStyleProject("upstream");
+ r.createFreeStyleProject("d0wnstr3'am");
+ upstream.getPublishersList().add(new BuildTrigger("d0wnstr3'am", Result.SUCCESS));
+ r.jenkins.rebuildDependencyGraph();
+ FreeStyleBuild b = r.buildAndAssertSuccess(upstream);
+ r.waitUntilNoActivity();
+ HtmlPage rsp = r.createWebClient().goTo(b.getUrl()+"console");
+ assertThat(rsp.querySelector(".console-output").asText(), containsString("Triggering a new build of"));
+ assertThat(String.valueOf(rsp.getAnchorByText("d0wnstr3'am").click().getWebResponse().getStatusCode()), containsString("200"));
+ }
+
private static String annotate(String text) throws IOException {
StringWriter writer = new StringWriter();
try (ConsoleAnnotationOutputStream out = new ConsoleAnnotationOutputStream(writer, null, null, StandardCharsets.UTF_8)) {